You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Asynchronous programming doesn't always require a programmer to think in terms of multiple threads. .Net's async\await is an object lesson in making difficult things seem simple.
Describe the solution you'd like
Consider the following method:
PublicSubUpdateDatabase(CustomerIdAsInteger)OnErrorGotoDatabaseError_connection.Execute("UPDATE MyTable SET IsActive = 1 WHERE CustomerId = @p1",CustomerId)DatabaseError:Msgbox"Failed"EndSub
This is a synchronous call which will block the thread until the database responds. We could solve this by offloading to a background thread, but then we have to worry about thread synchronisation, exception marshalling, and protecting shared-state variables.
The async\await apparatus in .Net allows us to write async code in a very similar style to synchronous code:
PublicAsyncFunctionUpdateDatabase(CustomerIdAsInteger)AsTaskOnErrorGotoDatabaseErrorAwait_connection.Execute("UPDATE MyTable SET IsActive = 1 WHERE CustomerId = @p1",CustomerId)DatabaseError:Msgbox"Failed"EndSub
Describe alternatives you've considered
Multi-threading can definitely achieve asynchrony, but it's kinda a sledgehammer to crack a nut when all you want to do is to carry on whilst you wait for an I/O operation to complete.
Additional context Async/Await is a classic example of making difficult things appear to be simple. I suspect Microsoft invested millions in making it work; it may be impossible for twinBASIC to replicate. For example, Awaiting inside of a loop requires the .Net compiler to rewrite sections of your code as a state machine. I may be asking for the moon here.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Asynchronous programming doesn't always require a programmer to think in terms of multiple threads. .Net's
async\await
is an object lesson in making difficult things seem simple.Describe the solution you'd like
Consider the following method:
This is a synchronous call which will block the thread until the database responds. We could solve this by offloading to a background thread, but then we have to worry about thread synchronisation, exception marshalling, and protecting shared-state variables.
The
async\await
apparatus in .Net allows us to write async code in a very similar style to synchronous code:Describe alternatives you've considered
Multi-threading can definitely achieve asynchrony, but it's kinda a sledgehammer to crack a nut when all you want to do is to carry on whilst you wait for an I/O operation to complete.
Additional context
Async/Await
is a classic example of making difficult things appear to be simple. I suspect Microsoft invested millions in making it work; it may be impossible for twinBASIC to replicate. For example, Awaiting inside of a loop requires the .Net compiler to rewrite sections of your code as a state machine. I may be asking for the moon here.The text was updated successfully, but these errors were encountered: