开发者

How to automatically run in the background?

I'm not sure that it's not implemented yet, I hope that it is. But I know that in .Net programmers should manually run time-consuming task i开发者_高级运维n the background thread.

So every time we handle some UI event and we understand that this will take some time we also understand that this will hang UI thread and our application. And then we make all this Background work things and handle callbacks or whatever.

So my question is:

Is there in some language/platform a mechanism that will automatically run time-consuming tasks in the background and will do all related work itself? So we just write the code for handling specific UI event and this code will be somehow detected as time-consuming and will be executed in background.

And if there isn't, then why?


There's been a lot of work done in Haskell (and other functional languages) to make it automatically do things in other threads. But Haskell's not the easiest GUI programming language.


You could look at something like Quartz for .Net. It's a job scheduler, but can be used to run time consuming processes in a background thread.


There is active research being done in this area, but it's a complex topic. For one example, see the Axum project by MS Research. It's a message-passing based DSL targetting the CLR.

I am not aware of any UI-specific languages, however. Most large frameworks (including .NET) have lots of tools for assisting the process of running tasks in the background.


There is not (as far as I know) and the reason for that is because the computer doesn't know ahead of time how long a certain task will take to complete. Make no mistake - a computer algorithm can be devised in particular cases by the programmer to determine the expected duration of a certain specific task - but at this time there is no way known to make a computer determine just how long any arbitrary task will take. This is a consequence of a very important Computer Science problem, called the Halting Problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜