locked
Asyn ConfigureWait Question RRS feed

  • Question

  • User-1188570427 posted

    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. 

    Tuesday, February 20, 2018 11:50 PM

Answers

  • User-1188570427 posted

    Perfect.

    This is what I needed to know and what I thought. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 22, 2018 12:40 PM

All replies

  • User283571144 posted

    Hi tvb2727,

    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

    Wednesday, February 21, 2018 5:25 AM
  • User-1188570427 posted

    Hi tvb2727,

    tvb2727

    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.

    Wednesday, February 21, 2018 1:01 PM
  • User283571144 posted

    Hi tvb2727,

    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 

    Thursday, February 22, 2018 7:00 AM
  • User-1188570427 posted

    Perfect.

    This is what I needed to know and what I thought. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 22, 2018 12:40 PM