How to automatically run in the background?
I'm not sure if it hasn't been implemented yet, I hope it is. But I know that .Net programmers have to manually run a time consuming task on a background thread.
So, every time we handle some UI events and we understand that it will take some time, we also understand that this will cause the UI thread and our application to hang. And then we do all this background work and handle callbacks or whatever.
So my question is:
Is there a mechanism in some language / platform that will automatically run multitasking tasks in the background and will do all the relevant work? So we just write code to handle a specific UI event, and that code will somehow be detected as time-consuming and executed in the background.
If not, why not?
a source to share
You can look at something like Quartz for. Net . This is a job scheduler, but it can be used to run long running processes on a background thread.
a source to share
There is active research in this area, but it is a complex topic. For example, see Project Axum from MS Research. This is a messaging DSL targeting the CLR.
However, I am not aware of any UI specific languages. Most major frameworks (including .NET) have many tools to support the process of executing tasks in the background.
a source to share
No (as far as I know), and the reason is that the computer does not know in advance how long it will take to complete a particular task. Make no mistake - a computer algorithm may be designed in certain cases by a programmer to determine the expected duration of a certain specific task, but it is currently unknown how a computer can determine how long any arbitrary task will take. This is a consequence of a very important problem in computer science called the Halting Problem .
a source to share