-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix: PictureBox.LoadAsync
throws PlatformNotSupportedException
#1696
fix: PictureBox.LoadAsync
throws PlatformNotSupportedException
#1696
Conversation
6a57e2b
to
a3bb61b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look correct to me, multithreading is hard :-/
What doesn't look correcT? |
Sorry, github didn't take my comments, I'll review again. Might have already adressed some of them ;-) |
No worries... I'm done for the day, no more force-pushes from me until tomorrow ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review didn't take my comments, trying again. Also had comments about reusability of the cancellation token but that seems to have been adressed already.
src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs
Outdated
Show resolved
Hide resolved
a3bb61b
to
bd1d8f3
Compare
Looks better to me now. Having read through it a few times I'm starting to feel a bit iffy on the cancellation. I think the old I wonder if its possible to get the PictureBox stuck in a canceled loading state:
Considering that the only point of the You'll probably want to take someone elses opinion on this, multithreading is indeed hard :-( |
Async delegates have been deprecated in .NET Core (see https://github.com/dotnet/corefx/issues/5940) for reasons such as: * Async delegates use deprecated IAsyncResult-based async pattern. This pattern is generally not supported throughout .NET Core base libraries. * Async delegates depend on remoting (System.Runtime.Remoting) under the hood. Remoting is not supported in .NET Core. For more detailed reasons and migration strategies please refer to https://devblogs.microsoft.com/dotnet/migrating-delegate-begininvoke-calls-for-net-core/ In case of WinForms, async pattern predates the Task-based Asynchronous Pattern and it does not return awaitables. In order to minimise the change to the public API surface we continue to expose the existing API and just re-route the image loading routine to a `Task` runner under the covers. Fixes dotnet#242 Fixes dotnet#1548
bd1d8f3
to
e8bb804
Compare
Codecov Report
@@ Coverage Diff @@
## release/3.0 #1696 +/- ##
====================================================
- Coverage 25.95534% 25.9456% -0.00974%
====================================================
Files 804 804
Lines 267706 267714 +8
Branches 37950 37951 +1
====================================================
- Hits 69484 69460 -24
- Misses 193295 193327 +32
Partials 4927 4927
|
Your multi-threading kung-fu is better than mine and reasoning is more sound 😄 |
The fix is signed off by CTI, no regressions found. |
Tactics approved after final code reviews. |
@RussKie this is good to go. Please merge at your leisure |
{ | ||
// Invoke BeginGetResponse on a threadpool thread, as it has unpredictable latency | ||
req.BeginGetResponse(new AsyncCallback(GetResponseCallback), req); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephentoub Can con confirm this is the expected translation for a BeginInvoke
usage like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reasonable.
(Though I don't think the comment is relevant on .NET Core, so it's not clear how relevant this queueing is anymore. Plus, it'd be better to switch to a cached HttpClient instead of using WebRequest.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus, it'd be better to switch to a cached HttpClient instead of using WebRequest
Certainly, Sam has already flagged it offline.
We will replace WebRequest
in .NET 5.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Fixes #242
Fixes #1548
Proposed changes
Async delegates have been deprecated in .NET Core (see https://github.com/dotnet/corefx/issues/5940) for reasons such as:
For more detailed reasons and migration strategies please refer to https://devblogs.microsoft.com/dotnet/migrating-delegate-begininvoke-calls-for-net-core/
In case of WinForms, async pattern predates the Task-based Asynchronous Pattern and it does not return awaitables.
In order to minimise the change to the public API surface we continue to expose the existing API and just re-route the image loading routine to a
Task
runner under the covers.Customer Impact
Regression?
Risk
Test methodology
Microsoft Reviewers: Open in CodeFlow