-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullException when using Dispatcher.AwaitableRunAsync with Action #608
Comments
taskCompletionSource.SetResult(await function().ConfigureAwait(false)); will raise NulLException if function return null |
Ping @Code-ScottLe |
Ooohf. Dang. I'll get on it after work. |
@deltakosh Do you have an example of this failing? |
I'm Publishing a fix in 2 mins but what cause it int crossThreadReturnedValue = await Task.Run(async () =>
|
This call doesn't specified the return value type |
No the return type is Task :) not the T |
I was wondering how this happening until I saw Func of Task of T , Task is the return type :) that's why it allowed null. |
but in the code above, the call is awaited the returned Task and try to assign the returned value to an int, which should be caught by Intellisense / Compiler right? Or should i ignore that part ? :) |
lol :) you're totally right maybe we should report this to the VS team. |
Or maybe it is designed to be like that. |
Ya, i was like, "wait what?, how does one that even pass the compiler!?" The |
No the Task that is returned from the function is the Null not the func it self and that's why when the task(Null).configureAwait will throw a null reference :) |
Oh! I see. So the entire returned Task itself is null? In which case does that happen? |
int returnedFromUIThread = await DispatcherHelper.ExecuteOnUIThreadAsync(() => |
Hmm, i'm still scratching my head over here on how this call ended up using the
is an |
I was just like that the moment I saw it :) but after investigation I noticed the |
So is the returned value of the call above (not the lambda) is |
Yes :) |
If that is the case, then i don't get it why the lambda passed compiling then, |
ping @lukasf |
let me explain it from my point of view :) |
Yeah, i understand your reasoning. So it is almost like :
But the call is a straight forward |
Thank you guys! it was an interesting one :) |
heheh yes :) for a second I thought VS has a bug :D |
No, the code uses the generic one :) but I see that github removed the greater than sign :) |
Ohhh... now that makes sense now... you got me for a solid hour there hahahahaha. Thanks for fixing this, I appreciate it. :) |
You're welcome :) |
Wow, nice one! Pretty weird but somehow it makes sense, from the compiler's point of view... :) |
No description provided.
The text was updated successfully, but these errors were encountered: