Friday, 15 July 2011

multithreading - How not to let application exit when tasks are running -


Are there any framework support for applications to close, but there are some unfinished tasks?

Tasks go by default in the context of background threads. Sometimes it's OK to fix this task:

  Tasks Factor STARTNU ((=) = & gt; {thread current.IsBackground = true;});   

But this does not work if the work needs to be turned on for which integration is required. Especially if some work will run under UI threads.
It is possible to achieve all the "last" tasks and exit whenAll () . However, when I use ASCIN / wait, how do I do that?

So I want to know whether there is any support for such cases or not. Are there any guarantees that the framework gives or how to implement them?

Now the only way is setting the flag as a sign that important functions have not yet been completed.

As a side, you do not set IsBackground on the thread pool thread should do.

For the async methods, make sure that your methods are returning tasks and not , and then you You can wait using when all to all your event handlers instead of task to wait Can occupy the top.

No comments:

Post a Comment