views:

58

answers:

4

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 in 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?

A: 

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.

davek
Looks like still too much redundant work or may be I'm just too lazy :)
Hun1Ahpu
+1  A: 

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.

Kristopher Johnson
A: 

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.

Reed Copsey
You're right - have lots of tools. But I'm asking about why it's not automatic. I'm not talking about sophisticated multi-threaded apps, just simple UI thread - Background thread conversation.
Hun1Ahpu
A: 

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.

Miky Dinescu