Skip to content

Commit

Permalink
[net7.0] Update Essentials MainThread API Docs (#12143)
Browse files Browse the repository at this point in the history
* Update Essentials MainThread API Docs

* Update MainThread.netstandard.cs

* Update src/Essentials/src/MainThread/MainThread.shared.cs

Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 15, 2022
1 parent d1ba6e0 commit 260491a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 182 deletions.
173 changes: 0 additions & 173 deletions src/Essentials/docs/Microsoft.Maui.Essentials/MainThread.xml

This file was deleted.

1 change: 0 additions & 1 deletion src/Essentials/src/MainThread/MainThread.netstandard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Microsoft.Maui.ApplicationModel
{
/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="Type[@FullName='Microsoft.Maui.Essentials.MainThread']/Docs/*" />
public static partial class MainThread
{
static void PlatformBeginInvokeOnMainThread(Action action) =>
Expand Down
44 changes: 36 additions & 8 deletions src/Essentials/src/MainThread/MainThread.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@

namespace Microsoft.Maui.ApplicationModel
{
/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="Type[@FullName='Microsoft.Maui.Essentials.MainThread']/Docs/*" />
/// <summary>
/// The MainThread class allows applications to run code on the main thread of execution, and to determine if a particular block of code is currently running on the main thread.
/// </summary>
public static partial class MainThread
{
/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='IsMainThread']/Docs/*" />
/// <summary>
/// True if the current thread is the UI thread.
/// </summary>
public static bool IsMainThread =>
PlatformIsMainThread;

/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='BeginInvokeOnMainThread']/Docs/*" />
/// <summary>
/// Invokes an action on the main thread of the application.
/// </summary>
/// <param name="action">The action to invoke on the main thread.</param>
public static void BeginInvokeOnMainThread(Action action)
{
if (IsMainThread)
Expand All @@ -24,7 +31,11 @@ public static void BeginInvokeOnMainThread(Action action)
}
}

/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='InvokeOnMainThreadAsync'][1]/Docs/*" />
/// <summary>
/// Invokes an action on the main thread of the application asynchronously.
/// </summary>
/// <param name="action">The action to invoke on the main thread.</param>
/// <returns>A <see cref="Task"/> object with the current status of the asynchronous operation.</returns>
public static Task InvokeOnMainThreadAsync(Action action)
{
if (IsMainThread)
Expand All @@ -51,7 +62,12 @@ public static Task InvokeOnMainThreadAsync(Action action)
return tcs.Task;
}

/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='InvokeOnMainThreadAsync&lt;T&gt;'][2]/Docs/*" />
/// <summary>
/// Invokes a function on the main thread of the application asynchronously.
/// </summary>
/// <typeparam name="T">Type of the object to be returned.</typeparam>
/// <param name="func">The function task to execute on the main thread.</param>
/// <returns>A <see cref="Task"/> object that can be awaited to capture the result object.</returns>
public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func)
{
if (IsMainThread)
Expand All @@ -77,7 +93,11 @@ public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func)
return tcs.Task;
}

/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='InvokeOnMainThreadAsync'][2]/Docs/*" />
/// <summary>
/// Invokes a function on the main thread of the application asynchronously.
/// </summary>
/// <param name="funcTask">The function task to execute on the main thread.</param>
/// <returns>A <see cref="Task"/> object that can be awaited.</returns>
public static Task InvokeOnMainThreadAsync(Func<Task> funcTask)
{
if (IsMainThread)
Expand All @@ -104,7 +124,12 @@ public static Task InvokeOnMainThreadAsync(Func<Task> funcTask)
return tcs.Task;
}

/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='InvokeOnMainThreadAsync&lt;T&gt;'][1]/Docs/*" />
/// <summary>
/// Invokes a function on the main thread of the application asynchronously.
/// </summary>
/// <typeparam name="T">Type of the object to be returned.</typeparam>
/// <param name="funcTask">The function task to execute on the main thread.</param>
/// <returns>A <see cref="Task"/> object that can be awaited to capture the result object.</returns>
public static Task<T> InvokeOnMainThreadAsync<T>(Func<Task<T>> funcTask)
{
if (IsMainThread)
Expand All @@ -131,7 +156,10 @@ public static Task<T> InvokeOnMainThreadAsync<T>(Func<Task<T>> funcTask)
return tcs.Task;
}

/// <include file="../../docs/Microsoft.Maui.Essentials/MainThread.xml" path="//Member[@MemberName='GetMainThreadSynchronizationContextAsync']/Docs/*" />
/// <summary>
/// Gets the main thread synchonization context.
/// </summary>
/// <returns>The synchronization context for the main thread.</returns>
public static async Task<SynchronizationContext> GetMainThreadSynchronizationContextAsync()
{
SynchronizationContext ret = null;
Expand Down

0 comments on commit 260491a

Please sign in to comment.