0

Basically I am an android developer,now working in windows.Could anyone please let me know if there is any way to start asynchronous task with pre post executes similar to android?

Thanks in advance :)

Remmyabhavan
  • 1,689
  • 5
  • 36
  • 65
  • You should mention if you are using managed code (.NET Compact Framework) or native code (C++ / Win32 API / MFC / WTL ) development. – Trevor Balcom May 17 '11 at 17:19

2 Answers2

0

I'm not familiar with Android, but if you want to execute an asynchronous task, you have two options:

  1. Use a thread to execute the task in-process. In C# that would be the Thread or ThreadPool class, in C++ it's CreateThread.
  2. Spawn a separate process completely for the task. In C# that would be done with the Process class. In C++ it would be CreateProcess (or ShellExecuteEx).

Without knowing more about your "task", your code environment and the launching process it's difficult to be any more targeted in my answer.

EDIT

Further investigation leads me to believe that you're talking about an in-proce callback from an asynchronous thread execution, so you're very likely after a thread (though a timer might also achieve what you want, depending on exactly what you're after). How to implement it is very different depending on the language you're using. Let us know what language you're developing in and we can give you better direction.

ctacke
  • 66,480
  • 18
  • 94
  • 155
0

Your question has already been answered.

I ended up solving this issue using the 3rd party BackgroundWorker implementation mentioned in the link I provided.

Community
  • 1
  • 1
Trevor Balcom
  • 3,766
  • 2
  • 32
  • 51
  • It's only "already answered" if he's using managed code, and it's still not clear that a BackgroundWorker will do it. It looks like he wants to not just exeute a background task, but also do something back on the calling thread when that task completes – ctacke May 17 '11 at 17:27
  • BackgroundWorker has the DoWork and RunWorkerCompleted events. It certainly supports the ability to do something when the task completes. – Trevor Balcom May 17 '11 at 18:43