Delegates.Extensions.Diagnostics
0.2.0
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package Delegates.Extensions.Diagnostics --version 0.2.0
NuGet\Install-Package Delegates.Extensions.Diagnostics -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Delegates.Extensions.Diagnostics" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Delegates.Extensions.Diagnostics --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Delegates.Extensions.Diagnostics, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Delegates.Extensions.Diagnostics as a Cake Addin #addin nuget:?package=Delegates.Extensions.Diagnostics&version=0.2.0 // Install Delegates.Extensions.Diagnostics as a Cake Tool #tool nuget:?package=Delegates.Extensions.Diagnostics&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Diagnostic.Extensions
Delegates.Extensions.Diagnostics
What did it do.
public static Action Diagnostic(this Action action, string? category = null, object? data = null)
{
DiagnosticListener.Write("Delegates.Extensions.{category}.Preparing");
Action wrapped = () =>
{
DiagnosticListener.Write("Delegates.Extensions.{category}.Executing");
try
{
action();
DiagnosticListener.Write("Delegates.Extensions.{category}.Succeed");
}
catch (Exception ex)
{
DiagnosticListener.Write("Delegates.Extensions.{category}.Exceptional");
throw;
}
finally
{
DiagnosticListener.Write("Delegates.Extensions.{category}.Finished");
}
};
DiagnosticListener.Write("Delegates.Extensions.{category}.Prepared");
return wrapped;
}
What you can do.
Task.Run(((Action)Call).Diagnostic("Timing"));
// or
Task.Run(new DiagnosticAction("Timing", Call));
void Call() { }
internal class Listener : IObserver<KeyValuePair<string, object>>
{
public void OnNext(KeyValuePair<string, object> value)
{
switch (value.Key)
{
case "Delegates.Extensions.Timing.Preparing":
((PreparingContext)value.Value).Cabinet["prepare"] = Stopwatch.StartNew();;
break;
case "Delegates.Extensions.Timing.Executing":
var stopwatch = (Stopwatch)((ExecutingContext)value.Value).Cabinet["prepare"];
stopwatch.Stop();
Console.WriteLine($"enqueue task costs {prepare.ElapsedMilliseconds}ms");
break;
}
}
}
Wrap Func<Task>
or Func<Task<T>>
// define a async Method
public async Task<int> CallAsync(int delay)
{
await Task.Delay(delay);
await new HttpClient().GetAsync("https://github.com");
return delay;
}
// await directly
await CallAsync(100);
// without await
CallAsync(100);
// await with wrap
await new DiagnosticFunc<Task<int>>("my-category", () => CallAsync(100));
// without await but wrap
new DiagnosticFunc<Task<int>>("my-category", () => CallAsync(100)).Invoke();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- System.Diagnostics.DiagnosticSource (>= 4.7.1)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net5.0
- System.Diagnostics.DiagnosticSource (>= 5.0.0)
-
net6.0
- System.Diagnostics.DiagnosticSource (>= 6.0.0)
-
net7.0
- System.Diagnostics.DiagnosticSource (>= 7.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Delegates.Extensions.Diagnostics:
Package | Downloads |
---|---|
SpanableSkyAPM.Diagnostics.Delegates
SpanableSkyAPM.Diagnostics.Delegates notifies of Delegates messages. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.2.0 | 7,631 | 3/8/2023 | |
0.2.0-priview-1678184903 | 132 | 3/7/2023 | |
0.2.0-priview-1678182218 | 133 | 3/7/2023 | |
0.1.0 | 280 | 3/3/2023 | |
0.1.0-beta | 135 | 3/3/2023 |
Support Action, Func<>, Func<, Task>, Func<, Task<TResult>>, ParameterizedThreadStart, ThreadStart, TimerCallback and WaitCallback.