Skip to content
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

Add first WinForms Async experimental APIs #11828

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d43855a
Fix CTI backwards compatibility test issues.
KlausLoeffelmann Aug 7, 2024
fc8b256
Fix ExperimentalAttrinute url const.
KlausLoeffelmann Aug 8, 2024
7f7c0d0
Address additional feedback review.
KlausLoeffelmann Aug 8, 2024
bace995
Fix backwards compat issue in Application.RenderWithVisualStyles.
KlausLoeffelmann Aug 8, 2024
cf32e9c
Fix some CTI found issues around the new form border attributes APIs.
KlausLoeffelmann Aug 9, 2024
d4c454e
First draft of Darkmode for ToolStrips.
KlausLoeffelmann Aug 30, 2022
612d679
First draft of DarkMode implementation.
KlausLoeffelmann Aug 23, 2022
5e779a1
Fix merge issues.
KlausLoeffelmann Jul 17, 2023
be97775
Fixing merge issues.
KlausLoeffelmann Jun 22, 2024
e662763
Introduce WinForms Async support.
KlausLoeffelmann Aug 23, 2022
023c8ae
Refactor WinForms async features.
KlausLoeffelmann Jul 18, 2024
804fa03
Refactor InvokeAsync implementation.
KlausLoeffelmann Jul 18, 2024
6717274
Refactor and clean up code.
KlausLoeffelmann Jul 30, 2024
4465b61
Add Form.ShowAsync to async API.
KlausLoeffelmann Jul 30, 2024
7fdd13e
Refactor Async functions based on new Diagnostic IDs.
KlausLoeffelmann Aug 1, 2024
615dd70
Refactor Form.ShowAsync and Form.ShowDialogAsync.
KlausLoeffelmann Aug 1, 2024
c37aedf
Refactor InvokeAsync.
KlausLoeffelmann Aug 2, 2024
c3ae459
Refactor Form.ShowAsync and Form.ShowDialogAsync.
KlausLoeffelmann Aug 6, 2024
c0fe9eb
Add improved handling of Exceptions in Form.ShowAsync scenarios.
KlausLoeffelmann Aug 6, 2024
2b2a2a3
Switch out experimental URL.
KlausLoeffelmann Aug 6, 2024
900e5c6
Ensure, we're not setting task completion results twice.
KlausLoeffelmann Aug 7, 2024
71b6034
Finalize Invoke async including the docs.
KlausLoeffelmann Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ dotnet_diagnostic.CA1846.severity = error
# CA2246: Do not assign a symbol and its member in the same statement
dotnet_diagnostic.CA2246.severity = error

# CA1855: Use Span<T>
.Clear() instead of Span<T>.Fill()
# CA1855: Use Span<T>.Clear() instead of Span<T>.Fill()
dotnet_diagnostic.CA1855.severity = error

# CA1857: The parameter expects a constant for optimal performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices

#Disable Warning WFO5001
#Disable Warning WFO5000

Friend Sub New(minimumSplashScreenDisplayTime As Integer,
highDpiMode As HighDpiMode,
colorMode As SystemColorMode,
Expand All @@ -28,8 +29,8 @@ Namespace Microsoft.VisualBasic.ApplicationServices
Me.HighDpiMode = highDpiMode
Me.ColorMode = colorMode
Me.VisualStylesMode = visualStylesMode

End Sub

#Enable Warning WFO5000
#Enable Warning WFO5001

Expand All @@ -46,7 +47,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
''' Setting this Property inside the event handler determines how long an application's Splash dialog is displayed at a minimum.
''' </summary>
Public Property MinimumSplashScreenDisplayTime As Integer =
WindowsFormsApplicationBase.MINIMUM_SPLASH_EXPOSURE_DEFAULT
WindowsFormsApplicationBase.MinimumSplashExposureDefault

''' <summary>
''' Setting this Property inside the event handler determines the general HighDpiMode for the application.
Expand All @@ -59,14 +60,14 @@ Namespace Microsoft.VisualBasic.ApplicationServices
''' <summary>
''' Setting this property inside the event handler determines the <see cref="Application.ColorMode"/> for the application.
''' </summary>
<Experimental(DiagnosticIDs.ExperimentalDarkMode)>
<Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat:=WindowsFormsApplicationBase.WinFormsExperimentalUrl)>
Public Property ColorMode As SystemColorMode

''' <summary>
''' Setting this property inside the event handler determines the <see cref="VisualStylesMode"/> for the application.
''' </summary>
''' <returns></returns>
<Experimental(DiagnosticIDs.ExperimentalVisualStyles)>
<Experimental(DiagnosticIDs.ExperimentalVisualStyles, UrlFormat:=WindowsFormsApplicationBase.WinFormsExperimentalUrl)>
Public Property VisualStylesMode As VisualStylesMode

End Class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ Namespace Microsoft.VisualBasic.ApplicationServices
Private Delegate Sub DisposeDelegate()

' How long a subsequent instance will wait for the original instance to get on its feet.
Private Const SECOND_INSTANCE_TIMEOUT As Integer = 2500 ' milliseconds.
Private Const SecondInstanceTimeOut As Integer = 2500 ' milliseconds.

Friend Const MINIMUM_SPLASH_EXPOSURE_DEFAULT As Integer = 2000 ' milliseconds.
Friend Const MinimumSplashExposureDefault As Integer = 2000 ' milliseconds.
Friend Const WinFormsExperimentalUrl As String = "https://aka.ms/winforms-experimental/{0}"

Private ReadOnly _splashLock As New Object
Private ReadOnly _appContext As WinFormsAppContext
Expand Down Expand Up @@ -133,7 +134,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
Private _splashScreen As Form

' Minimum amount of time to show the splash screen. 0 means hide as soon as the app comes up.
Private _minimumSplashExposure As Integer = MINIMUM_SPLASH_EXPOSURE_DEFAULT
Private _minimumSplashExposure As Integer = MinimumSplashExposureDefault
Private _splashTimer As Timers.Timer
Private _appSynchronizationContext As SynchronizationContext

Expand Down Expand Up @@ -360,7 +361,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices

' --- We are launching a subsequent instance.
Dim tokenSource As New CancellationTokenSource()
tokenSource.CancelAfter(SECOND_INSTANCE_TIMEOUT)
tokenSource.CancelAfter(SecondInstanceTimeOut)
Try
Dim awaitable As ConfiguredTaskAwaitable = SendSecondInstanceArgsAsync(
pipeName:=applicationInstanceID,
Expand Down Expand Up @@ -835,7 +836,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
''' <returns>
''' The <see cref="VisualStylesMode"/> that the application is running in.
''' </returns>
<Experimental(DiagnosticIDs.ExperimentalVisualStyles)>
<Experimental(DiagnosticIDs.ExperimentalVisualStyles, UrlFormat:=WinFormsExperimentalUrl)>
<EditorBrowsable(EditorBrowsableState.Never)>
Protected Property VisualStylesMode As VisualStylesMode
Get
Expand All @@ -852,7 +853,7 @@ Namespace Microsoft.VisualBasic.ApplicationServices
''' <returns>
''' The <see cref="SystemColorMode"/> that the application is running in.
''' </returns>
<Experimental(DiagnosticIDs.ExperimentalDarkMode)>
<Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat:=WinFormsExperimentalUrl)>
<EditorBrowsable(EditorBrowsableState.Never)>
Protected Property ColorMode As SystemColorMode
Get
Expand Down
1 change: 0 additions & 1 deletion src/System.Private.Windows.Core/src/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ E_OUTOFMEMORY
E_POINTER
E_UNEXPECTED
EncoderParameters
ExtSelectClipRgn
fdex*
FDEX_PROP_FLAGS
FILETIME
Expand Down
1 change: 0 additions & 1 deletion src/System.Windows.Forms/src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.ToolStripScrollButton.t_downScrollImage")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.ToolStripSystemRenderer.t_renderer")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.TrackBarRenderer.t_visualStyleRenderer")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.MessageBox.t_helpInfoTable")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.ErrorProvider.t_defaultIcon")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.DockingAttribute.Default")]
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Thread local", Scope = "member", Target = "~F:System.Windows.Forms.NativeWindow.t_anyHandleCreated")]
Expand Down
11 changes: 11 additions & 0 deletions src/System.Windows.Forms/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ override System.Windows.Forms.CheckBox.OnPaint(System.Windows.Forms.PaintEventAr
static System.Windows.Forms.Application.ColorMode.get -> System.Windows.Forms.SystemColorMode
static System.Windows.Forms.Application.SetColorMode(System.Windows.Forms.SystemColorMode systemColorMode) -> void
static System.Windows.Forms.Application.SystemColorMode.get -> System.Windows.Forms.SystemColorMode
static System.Windows.Forms.TaskDialog.ShowDialogAsync(nint hwndOwner, System.Windows.Forms.TaskDialogPage! page) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
static System.Windows.Forms.TaskDialog.ShowDialogAsync(nint hwndOwner, System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.TaskDialogPage! page) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
System.Windows.Forms.Control.InvokeAsync(System.Action! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
System.Windows.Forms.Control.InvokeAsync(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
System.Windows.Forms.Control.InvokeAsync<T>(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<T>>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<T>!
System.Windows.Forms.Control.InvokeAsync<T>(System.Func<T>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<T>!
System.Windows.Forms.Form.FormBorderColor.get -> System.Drawing.Color
System.Windows.Forms.Form.FormBorderColor.set -> void
System.Windows.Forms.Form.FormBorderColorChanged -> System.EventHandler?
Expand All @@ -14,6 +22,9 @@ System.Windows.Forms.Form.FormCaptionTextColorChanged -> System.EventHandler?
System.Windows.Forms.Form.FormCornerPreference.get -> System.Windows.Forms.FormCornerPreference
System.Windows.Forms.Form.FormCornerPreference.set -> void
System.Windows.Forms.Form.FormCornerPreferenceChanged -> System.EventHandler?
System.Windows.Forms.Form.ShowAsync(System.Windows.Forms.IWin32Window? owner = null) -> System.Threading.Tasks.Task!
System.Windows.Forms.Form.ShowDialogAsync() -> System.Threading.Tasks.Task<System.Windows.Forms.DialogResult>!
System.Windows.Forms.Form.ShowDialogAsync(System.Windows.Forms.IWin32Window! owner) -> System.Threading.Tasks.Task<System.Windows.Forms.DialogResult>!
System.Windows.Forms.FormCornerPreference
System.Windows.Forms.FormCornerPreference.Default = 0 -> System.Windows.Forms.FormCornerPreference
System.Windows.Forms.FormCornerPreference.DoNotRound = 1 -> System.Windows.Forms.FormCornerPreference
Expand Down
12 changes: 12 additions & 0 deletions src/System.Windows.Forms/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7018,4 +7018,16 @@ Stack trace where the illegal operation occurred was:
<data name="ControlVisualStylesModeChangedDescr" xml:space="preserve">
<value>Event raised whenever the VisualStylesMode property changes.</value>
</data>
<data name="FormOrTaskDialog_NoSyncContextForShowAsync" xml:space="preserve">
<value>Failed to retrieve the Synchronization Context for showing the Form asynchronously.</value>
</data>
<data name="Form_HasAlreadyBeenShownAsync" xml:space="preserve">
<value>The form has already been shown asynchronously.</value>
</data>
<data name="Application_ClassicVisualStyleHadAlreadyBeenSet" xml:space="preserve">
<value>Classic VisualStyles had already been set. If you want to set the VisualStylesMode to Disabled, make sure that you a) do not call EnableVisualStyles before or b) do not activate it in the Project settings.</value>
</data>
<data name="Application_VisualStylesModeCanOnlyBeSetOnce" xml:space="preserve">
<value>The VisualStylesMode had already been set for this Application. Make sure, that you set this value only once.</value>
</data>
</root>
20 changes: 20 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading