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

Update SyncAsyncEventArgs APIs #18437

Merged
merged 4 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core/api/Azure.Core.net461.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ protected Response() { }
}
public partial class SyncAsyncEventArgs : System.EventArgs
{
public SyncAsyncEventArgs(bool runSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
public SyncAsyncEventArgs(bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
public System.Threading.CancellationToken CancellationToken { get { throw null; } }
public bool RunSynchronously { get { throw null; } }
public bool IsRunningSynchronously { get { throw null; } }
}
}
namespace Azure.Core
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ protected Response() { }
}
public partial class SyncAsyncEventArgs : System.EventArgs
{
public SyncAsyncEventArgs(bool runSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
public SyncAsyncEventArgs(bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
public System.Threading.CancellationToken CancellationToken { get { throw null; } }
public bool RunSynchronously { get { throw null; } }
public bool IsRunningSynchronously { get { throw null; } }
}
}
namespace Azure.Core
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ protected Response() { }
}
public partial class SyncAsyncEventArgs : System.EventArgs
{
public SyncAsyncEventArgs(bool runSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
public SyncAsyncEventArgs(bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { }
public System.Threading.CancellationToken CancellationToken { get { throw null; } }
public bool RunSynchronously { get { throw null; } }
public bool IsRunningSynchronously { get { throw null; } }
}
}
namespace Azure.Core
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/samples/Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ example handler that's safe to invoke from both sync and async code paths.
var client = new AlarmClient();
client.Ring += async (SyncAsyncEventArgs e) =>
{
if (e.RunSynchronously)
if (e.IsRunningSynchronously)
{
Console.WriteLine("Wake up!");
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/core/Azure.Core/src/SyncAsyncEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public class SyncAsyncEventArgs : EventArgs
/// and serious performance problems.
/// </para>
/// <para>
/// You can use this <see cref="RunSynchronously"/> property to check
/// You can use this <see cref="IsRunningSynchronously"/> property to check
/// how the event is being raised and implement your handler
/// accordingly. Here's an example handler that's safe to invoke from
/// both sync and async code paths.
/// <code snippet="Snippet:Azure_Core_Samples_EventSamples_CombinedHandler">
/// var client = new AlarmClient();
/// client.Ring += async (SyncAsyncEventArgs e) =&gt;
/// {
/// if (e.RunSynchronously)
/// if (e.IsRunningSynchronously)
/// {
/// Console.WriteLine(&quot;Wake up!&quot;);
/// }
Expand All @@ -54,7 +54,7 @@ public class SyncAsyncEventArgs : EventArgs
/// </code>
/// </para>
/// </remarks>
public bool RunSynchronously { get; }
public bool IsRunningSynchronously { get; }

/// <summary>
/// Gets a cancellation token related to the original operation that
Expand All @@ -72,7 +72,7 @@ public class SyncAsyncEventArgs : EventArgs
/// Initializes a new instance of the <see cref="SyncAsyncEventArgs"/>
/// class.
/// </summary>
/// <param name="runSynchronously">
/// <param name="isRunningSynchronously">
/// A value indicating whether the event handler was invoked
/// synchronously or asynchronously. Please see
/// <see cref="Azure.Core.SyncAsyncEventHandler{T}"/> for more details.
Expand All @@ -84,10 +84,10 @@ public class SyncAsyncEventArgs : EventArgs
/// that take a token so cancellation will correctly propagate. The
/// default value is <see cref="CancellationToken.None"/>.
/// </param>
public SyncAsyncEventArgs(bool runSynchronously, CancellationToken cancellationToken = default)
public SyncAsyncEventArgs(bool isRunningSynchronously, CancellationToken cancellationToken = default)
: base()
{
RunSynchronously = runSynchronously;
IsRunningSynchronously = isRunningSynchronously;
CancellationToken = cancellationToken;
}
}
Expand Down
10 changes: 5 additions & 5 deletions sdk/core/Azure.Core/src/SyncAsyncEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ namespace Azure.Core
/// on a client. If you write an async handler but raise it from a sync
/// method, the handler will be doing sync-over-async and may cause
/// ThreadPool starvation. See the note in Remarks for more details. You
/// should use the <see cref="SyncAsyncEventArgs.RunSynchronously"/>
/// should use the <see cref="SyncAsyncEventArgs.IsRunningSynchronously"/>
/// property to check how the event is being raised and implement your
/// handler accordingly. Here's an example handler that's safe to invoke
/// from both sync and async code paths.
/// <code snippet="Snippet:Azure_Core_Samples_EventSamples_CombinedHandler">
/// var client = new AlarmClient();
/// client.Ring += async (SyncAsyncEventArgs e) =&gt;
/// {
/// if (e.RunSynchronously)
/// if (e.IsRunningSynchronously)
/// {
/// Console.WriteLine(&quot;Wake up!&quot;);
/// }
Expand Down Expand Up @@ -158,15 +158,15 @@ namespace Azure.Core
/// </item>
/// <item>
/// <description>
/// <see cref="SyncAsyncEventArgs.RunSynchronously"/> is a flag indicating
/// <see cref="SyncAsyncEventArgs.IsRunningSynchronously"/> is a flag indicating
/// whether your handler was invoked synchronously or asynchronously. If
/// you're calling sync methods on your client, you should use sync methods
/// to implement your event handler (you can return
/// <see cref="Task.CompletedTask"/>). If you're calling async methods on
/// your client, you should use async methods where possible to implement
/// your event handler. If you're not in control of how the client will be
/// used or want to write safer code, you should check the
/// <see cref="SyncAsyncEventArgs.RunSynchronously"/> property and call
/// <see cref="SyncAsyncEventArgs.IsRunningSynchronously"/> property and call
/// either sync or async methods as directed.
/// </description>
/// </item>
Expand Down Expand Up @@ -214,7 +214,7 @@ namespace Azure.Core
/// Diagnosing.NET Core ThreadPool Starvation with PerfView</see>
/// for a detailed explanation of how that can cause serious performance
/// problems. We recommend you use the
/// <see cref="SyncAsyncEventArgs.RunSynchronously"/> flag to avoid
/// <see cref="SyncAsyncEventArgs.IsRunningSynchronously"/> flag to avoid
/// ThreadPool starvation.
/// </para>
/// </remarks>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/tests/samples/EventSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task CombinedHandler()
var client = new AlarmClient();
client.Ring += async (SyncAsyncEventArgs e) =>
{
if (e.RunSynchronously)
if (e.IsRunningSynchronously)
{
Console.WriteLine("Wake up!");
}
Expand Down