Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42768

Wait for a thread to complete in Metro

In Metro, may I know how do you wait for a thread to complete. In conventional desktop app, to wait for the thread to complete, I will use

thread.Join()

However, how about in Metro?

// public void getSignalProcessingRunnable(IAsyncAction source) {}
IAsyncAction ThreadPoolWorkItem = Windows.System.Threading.ThreadPool.RunAsync(getSignalProcessingRunnable);
// How to wait for thread to complete?

Using await won't work.

Upvotes: 3

Views: 1615

Answers (1)

Furqan Safdar
Furqan Safdar

Reputation: 16718

If await is not working, you can also try using Task.WaitAny Method from MSDN

Task.WaitAny Method, Waits for any of the provided Task objects to complete execution.

Task.WaitAny(ThreadPoolWorkItem.AsTask());

You can also refer to this link: How to Start/Stop/Wait for a Thread

Also have a look on this good reference No Threads for you ! (in metro style apps)

Upvotes: 6

Related Questions