Closing Console Window From WPF

非 Y 不嫁゛ 提交于 2019-12-11 13:59:33

问题


I have a WPF project, when you click on a button, a Console application window Appears and do a long task (crawling some url that it got it from the wpf window). All of this works good, I have 2 problems.

  1. while the Console window is on, the WPF window freezes.
  2. if I closed the Console window, the whole application closes (including the wpf window).

For the Console Window, I implemented the class from John Leidegren in this post: No output to console from a WPF application?

then from my WPF project:

        public void StartCrawler (string url)
        {
        ConsoleManager.Show();
        Console.BufferHeight = Int16.MaxValue - 1;
        Console.SetWindowSize(122, 54);
          //using methods to display and crawl the given site
          //showing Console Messages for users with which sites are crowled  

        }

Is there any way to unfreeze my WPF project and when the Console window closes it doesn't affect it ? apart from creating a Console Application project and refer to its .exe ?

Thanks in advance.

来源:https://stackoverflow.com/questions/18378804/closing-console-window-from-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!