Bearbeiten

Freigeben über


Form.ShowDialogAsync Method

Definition

Overloads

ShowDialogAsync(IWin32Window)

Shows the form as a modal dialog box with the specified owner asynchronously.

ShowDialogAsync()

Shows the form as a modal dialog box asynchronously.

ShowDialogAsync(IWin32Window)

Shows the form as a modal dialog box with the specified owner asynchronously.

public:
 System::Threading::Tasks::Task<System::Windows::Forms::DialogResult> ^ ShowDialogAsync(System::Windows::Forms::IWin32Window ^ owner);
[System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public System.Threading.Tasks.Task<System.Windows.Forms.DialogResult> ShowDialogAsync (System.Windows.Forms.IWin32Window owner);
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
member this.ShowDialogAsync : System.Windows.Forms.IWin32Window -> System.Threading.Tasks.Task<System.Windows.Forms.DialogResult>
Public Function ShowDialogAsync (owner As IWin32Window) As Task(Of DialogResult)

Parameters

owner
IWin32Window

Any object that implements IWin32Window that represents the top-level window that will own the modal dialog box.

Returns

A Task<TResult> representing the outcome of the dialog. The task completes when the form is closed or disposed.

Attributes

Exceptions

The form is already displayed asynchronously.

-or-

No WindowsFormsSynchronizationContext could be retrieved or installed.

Remarks

The task will complete when the form is closed or disposed.

This method immediately returns, even if the form is large and takes a long time to be set up.

If the form is already displayed asynchronously by ShowAsync(IWin32Window), an InvalidOperationException will be thrown.

An InvalidOperationException will also occur if no WindowsFormsSynchronizationContext could be retrieved or installed.

There is no need to marshal the call to the UI thread manually if the call originates from a different thread. This is handled automatically.

Any exceptions that occur will be automatically propagated to the calling thread.

Applies to

ShowDialogAsync()

Shows the form as a modal dialog box asynchronously.

public:
 System::Threading::Tasks::Task<System::Windows::Forms::DialogResult> ^ ShowDialogAsync();
[System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public System.Threading.Tasks.Task<System.Windows.Forms.DialogResult> ShowDialogAsync ();
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5002", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
member this.ShowDialogAsync : unit -> System.Threading.Tasks.Task<System.Windows.Forms.DialogResult>
Public Function ShowDialogAsync () As Task(Of DialogResult)

Returns

A Task<TResult> representing the outcome of the dialog. The task completes when the form is closed or disposed.

Attributes

Exceptions

The form is already displayed asynchronously.

-or-

No WindowsFormsSynchronizationContext could be retrieved or installed.

Remarks

The task will complete when the form is closed or disposed.

This method immediately returns, even if the form is large and takes a long time to be set up.

If the form is already displayed asynchronously by ShowAsync(IWin32Window), an InvalidOperationException will be thrown.

An InvalidOperationException will also occur if no WindowsFormsSynchronizationContext could be retrieved or installed.

There is no need to marshal the call to the UI thread manually if the call originates from a different thread. This is handled automatically.

Any exceptions that occur will be automatically propagated to the calling thread.

Applies to