none
async await not working RRS feed

  • Question

  • I am removing this questions. Nothing is really helping so I am going to try something else.

    • Edited by btb900 Monday, March 23, 2020 12:20 PM
    Sunday, March 22, 2020 4:24 AM

All replies

  • you should add ConfigureAwait (false) inside your tasks, as you don't want to await the result on the UI Thread:
    await Xstage.MoveAbsoluteAsync(X).ConfigureAwait(false);
    await Ystage.MoveAbsoluteAsync(Y).ConfigureAwait(false);
    etc.
    Btw.: your MoveWaferAsync is blocking on Task.WaitAll, so is not really async.

    When you set a breakpoint at Xstage.MoveAbsoluteAsync, what are the other Tasks at?
    And you are sure the "MoveAbsoluteXXX" methods don't have some sort of synchronization build in?
    As this seems to be hardware, might simply be that it can't do two motions at the same time...
    Sunday, March 22, 2020 6:29 AM
  • I just tried this :

       ThreadList.Add(Ystage.MoveAbsoluteAsync(Y).ConfigureAwait(false));

    and  I get an error saying :

    Severity Code Description Project File Line Suppression State
    Error CS1503 Argument 1: cannot convert from 'System.Runtime.CompilerServices.ConfiguredTaskAwaitable' to 'System.Threading.Tasks.Task'
    Sunday, March 22, 2020 4:25 PM
  • await multiple tasks with 
     await Task.WhenAll
    Sunday, March 22, 2020 4:36 PM
  • "I just tried this : ..."
    thats not what I wrote.
    async Task moveXTask (double X)
            {
               
                try
                {
                    await Xstage.MoveAbsoluteAsync(X).ConfigureAwait(false);               
                }
                catch ( Exception err)
                {
                    if (err.Message == "Motor timed out before action was completed")
                    {
                        double Xlocation = Math.Abs((Xstage.GetPosition() - X));
                        if (Xlocation > 1.1)
                        {
                         //   MessageBox.Show(err.Message + "Motor might not be in the right location");
    
    
                        }
                        await Xstage.resetMotor().ConfigureAwait(false);
                    }
                    else
                    {
                       // MessageBox.Show(err.Message);
                    }
                }
    
                
            }


    Sunday, March 22, 2020 5:10 PM
  • I tried it and it did not work...
    Sunday, March 22, 2020 9:39 PM
  • Tried it and it did not work 
    Sunday, March 22, 2020 9:39 PM
  • So what do you see in debugger?
    Sunday, March 22, 2020 11:56 PM