Do I need to set ConfigureWait(true) on every async call if I am waiting for a Loading... panel to work and response back? Or can I just call the first one with a ConfigureAwait(true) and then every other one to the database ConfigureAwait(false)?
Do I need to set ConfigureWait(true) on every async call if I am waiting for a Loading... panel to work and response back?
According to your description, I couldn't understand your requirement clearly.
Do you mean you want to show the loading panel when running the async task?
If you could post more details about your requirement, it will be more easily for us to understand the question.
As far as I know, the ConfigureAwait function is used to configure an awaiter used to await this Task.
Details about the ConfigureAwait, you could refer to this
answer.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Do I need to set ConfigureWait(true) on every async call if I am waiting for a Loading... panel to work and response back?
According to your description, I couldn't understand your requirement clearly.
Do you mean you want to show the loading panel when running the async task?
If you could post more details about your requirement, it will be more easily for us to understand the question.
As far as I know, the ConfigureAwait function is used to configure an awaiter used to await this Task.
Details about the ConfigureAwait, you could refer to this
answer.
Best Regards,
Brando
If you do ConfigureAwait(false) and another task kicks off, then it will go to another thread to run. I need it to return to the UI thread so that the message box comes up or a loading panel goes away. Otherwise, it will throw an error saying that the thread
is different and it can't return.
If you do ConfigureAwait(false) and another task kicks off, then it will go to another thread to run. I need it to return to the UI thread so that the message box comes up or a loading panel goes away. Otherwise, it will throw an error saying that the thread
is different and it can't return.
As far as I know, you need set ConfigureAwait(true) with all of the await to force the thread return back UI thread.
If you don't use this you will face error.
You could use Thread.CurrentThread.ManagedThreadId to see each thread id when you use ConfigureAwait(false).
You could find the main thread will always change.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Participant
1038 Points
2816 Posts
Asyn ConfigureWait Question
Feb 20, 2018 11:50 PM|tvb2727|LINK
Do I need to set ConfigureWait(true) on every async call if I am waiting for a Loading... panel to work and response back? Or can I just call the first one with a ConfigureAwait(true) and then every other one to the database ConfigureAwait(false)?
Thanks.
Star
9831 Points
3120 Posts
Re: Asyn ConfigureWait Question
Feb 21, 2018 05:25 AM|Brando ZWZ|LINK
Hi tvb2727,
According to your description, I couldn't understand your requirement clearly.
Do you mean you want to show the loading panel when running the async task?
If you could post more details about your requirement, it will be more easily for us to understand the question.
As far as I know, the ConfigureAwait function is used to configure an awaiter used to await this Task.
Details about the ConfigureAwait, you could refer to this answer.
Best Regards,
Brando
Participant
1038 Points
2816 Posts
Re: Asyn ConfigureWait Question
Feb 21, 2018 01:01 PM|tvb2727|LINK
If you do ConfigureAwait(false) and another task kicks off, then it will go to another thread to run. I need it to return to the UI thread so that the message box comes up or a loading panel goes away. Otherwise, it will throw an error saying that the thread is different and it can't return.
Star
9831 Points
3120 Posts
Re: Asyn ConfigureWait Question
Feb 22, 2018 07:00 AM|Brando ZWZ|LINK
Hi tvb2727,
As far as I know, you need set ConfigureAwait(true) with all of the await to force the thread return back UI thread.
If you don't use this you will face error.
You could use
Thread.CurrentThread.ManagedThreadId
to see each thread id when you use ConfigureAwait(false).You could find the main thread will always change.
Best Regards,
Brando
Participant
1038 Points
2816 Posts
Re: Asyn ConfigureWait Question
Feb 22, 2018 12:40 PM|tvb2727|LINK
Perfect.
This is what I needed to know and what I thought.