Lucian Wischik: Inside VB.NET Async and Customizing Awaitable Types
- Posted: Oct 28, 2010 at 10:14 AM
- 51,489 Views
- 9 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Lucian Wischik digs into the new VB functions and iterators being developed for asynchronous development. You can get an early look at these new features, available as the Async CTP, today! Give VB.NETAsync a try. In this whiteboard-heavy conversation, Lucian demonstrates how to make custom awaitable types and provides deep insights into the mechanics behind and inside Async.
Enjoy and please play with the CTP! The team is eager for your feedback.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
VB iterators, Async - MANY MANY thanks.
Method instances - WONDERFUL. That so much more matches how we think about it anyway without the redundant pain.
DAMN YOU Wischik!!! (wraith of khan stylee)
By implementing VB Iterators, what will us
VB.nuttersVB.netters berate Microsoftwith now.
mmm.
Yes
Unsafe?NoI think Extension Custom Operators would be interesting.
These custom operator have no precedence, so you need to use ( )'s accomplish it.
Notice the Public Operators code block, it just like a Sub but it isn't automatic imported into the namespace, you have do this explicitly. To enable the coder to override the built-in operator (ie a new language ones.), they would have to specify a "in this context" keywords.
Using Operator From { Ops_Double}
which can be nested with one another.
Using Operator From {namespace} Dim r as Double = 3 /¯ 27 ' r = 3 ( The cube root )' End UsingAdd 2 new keywords Operator & Operators.
Mmm Async Operators?
I know it takes vb.net into a rather strange world where the some of grammar is user-defined, but I strongly believe it would be useful and beneficial.
May be a concept proto-type language VB# (VB's c-omega).
I digress, congratulations and thank-you.
-Adam
P.S. I thought it was Godel?
This is a stellar going deep! Lucian is a great presenter.
It would be nice to have the same symmetry of design between asyncs and iterators in C# as exists in VB although performance is already an issue for iterators for some scenarios where it doesn't scale.
Also, I wonder how this new design will interact with proposals for making iterators more scalable; e.g. see this great post by Wesner Moise on the topic.
So design and interaction with compiler optimization is an interesting topic because when a feature is composable the next logical question must be: is it scalable. Can I take it to the extreme.
Performance woes aside, asyncs and iterators are superb features.
Agreed. I'd like to get Lucian on C9 again. He's super bright and articuate!
C
I agree we need more Lucian.
Possible one of the most useful benefits of having Iterators.
<Runtime.CompilerServices.Extension()> Public Iterator Function AsEnumerable(ByVal f As IEnumerator) As IEnumerable f.Reset() While f.MoveNext Yield f.Current End While f.Reset() End Function@AdamSpeight2008:
Kinda dangerous. Reset is might throw on some implementations.
I really liked the last question, because I have run into small problems with it.
It was actually Silverlight C# code and it went something like this...
I had I SaveFileDialog and a method, that used a StreamWriter passed to an async method
using (var writer = StreamWriter(dialog.OpenFile())) { WriteResults(writer, dialog.FilterIndex) } async void WriteResults(StreamWriter writer, int whatToExport) { if (whatToExport is something that isn't computed) { await TaskEx.Run(() => Compute(...)) } // write the result here // Raises an exception, that the stream is closed }This was definitely some behavior I was not expecting. But of course when I think about it, it makes perfect sense that it happened.
Now, originally the method WriteResults only wrote the results and later came the need to compute additional values before the actual export. So I kinda artificially extended the WriteResults method using Async because the computation could take several seconds and later I wanted to add a progress bar and cool stuff like this. I admit it was a bad "design" decision to do it this way (like I should open the file after the results are available). Nevertheless, it also means that there are some hidden pitfalls when using Async and one should be careful where it's being used.
So my suggestion is this: would it be possible to add a compiler warning if constructs like
using (var x = ...) { SomeAsyncMethod(x); }are used?
Lucian was excellent!!! I didn't get lost in translation LOL!!! He is so right about that everyone has the misconception of Async = background process
Great job Lucian !!
Lucian kicks * ! <a href=”http://www.etigararunway.ro">tigara electronica</a>
Remove this comment
Remove this thread
close