c# - Multiple await's inside an async method -


i have method

public async void getresult () 

that relies on 2 await responses inside of it.

this 1st: await:

await system.threading.tasks.task.factory.startnew (() => {                      try                      {                         scanneditem = getscanneditem();                      }                     catch (exception exe)                      { } 

and 2nd await await call uses scanneditem above

await system.threading.tasks.task.factory.startnew (() => {                      try                     {                         getresultsscanneditem = results(scanneditem);                      }                     catch (exception exe)                      { } 

i want have execute 1 button. however, second await never gets executed. can have 2 awaits inside method? bit confused on how go doing this.

yes can have multiple awaits inside single method .. these don't awaitable tasks .. wrapping them task factory.

you seem swallowing whatever exception happening within code.

try changing to:

await task.run(() => scanneditem = getscanneditem());  await task.run(() => getresultsscanneditem = results(scanneditem)); 

step through debugger , see if running or exception happening.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -