BreakHead
BreakHead

Reputation: 10672

Using Thread.Sleep() in Dispatcher.BeginInvoke's delegate

I am looking for the way to sleep the dispatcher thread but didn't found any way. I know there is 'this.Dispatcher.Thread' but I don't think i.e what I am looking for because it doesn't have sleep().

this.Dispatcher.BeginInvoke(new Action(() =>
            {
                                        //Thread.Sleep         

            }));

Upvotes: 1

Views: 796

Answers (1)

Lukazoid
Lukazoid

Reputation: 19416

When you use Thread.Sleep it sleeps the current thread, so when you do the following:

this.Dispatcher.BeginInvoke(new Action(() => Thread.Sleep(1000)));

It will sleep and freeze the UI thread for 1 second.

I strongly advise against this, however it should answer your question.

Upvotes: 1

Related Questions