##// END OF EJS Templates
Adde workaround to the behaviour of the logical operations stack in conjuction...
cin -
r255:b00441e04738 v3
parent child
Show More
@@ -0,0 +1,37
1 
2 Microsoft Visual Studio Solution File, Format Version 12.00
3 # Visual Studio 15
4 VisualStudioVersion = 15.0.27428.2005
5 MinimumVisualStudioVersion = 10.0.40219.1
6 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Implab", "Implab\Implab.csproj", "{FF2052B6-9C8F-4022-A347-F07ABF635885}"
7 EndProject
8 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Implab.Test", "Implab.Test\Implab.Test.csproj", "{6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}"
9 EndProject
10 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Playground", "Implab.Playground\Implab.Playground.csproj", "{100DFEB0-75BE-436F-ADDF-1F46EF433F46}"
11 EndProject
12 Global
13 GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 Debug|Any CPU = Debug|Any CPU
15 Release|Any CPU = Release|Any CPU
16 EndGlobalSection
17 GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Release|Any CPU.Build.0 = Release|Any CPU
22 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Release|Any CPU.Build.0 = Release|Any CPU
26 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Release|Any CPU.Build.0 = Release|Any CPU
30 EndGlobalSection
31 GlobalSection(SolutionProperties) = preSolution
32 HideSolutionNode = FALSE
33 EndGlobalSection
34 GlobalSection(ExtensibilityGlobals) = postSolution
35 SolutionGuid = {36D837FC-4CDD-4AEA-87BF-F130FEB22E02}
36 EndGlobalSection
37 EndGlobal
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="utf-8"?>
1 <?xml version="1.0" encoding="utf-8"?>
2 <configuration>
2 <configuration>
3 <startup>
3 <startup>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
5 </startup>
5 </startup>
6 </configuration>
6 </configuration>
@@ -1,69 +1,69
1 <?xml version="1.0" encoding="utf-8"?>
1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
3 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4 <PropertyGroup>
4 <PropertyGroup>
5 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 <ProjectGuid>{100DFEB0-75BE-436F-ADDF-1F46EF433F46}</ProjectGuid>
7 <ProjectGuid>{100DFEB0-75BE-436F-ADDF-1F46EF433F46}</ProjectGuid>
8 <OutputType>Exe</OutputType>
8 <OutputType>Exe</OutputType>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <RootNamespace>Implab.Playground</RootNamespace>
10 <RootNamespace>Implab.Playground</RootNamespace>
11 <AssemblyName>Implab.Playground</AssemblyName>
11 <AssemblyName>Implab.Playground</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12 <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13 <FileAlignment>512</FileAlignment>
13 <FileAlignment>512</FileAlignment>
14 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15 <TargetFrameworkProfile />
15 <TargetFrameworkProfile />
16 </PropertyGroup>
16 </PropertyGroup>
17 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18 <PlatformTarget>AnyCPU</PlatformTarget>
18 <PlatformTarget>AnyCPU</PlatformTarget>
19 <DebugSymbols>true</DebugSymbols>
19 <DebugSymbols>true</DebugSymbols>
20 <DebugType>full</DebugType>
20 <DebugType>full</DebugType>
21 <Optimize>false</Optimize>
21 <Optimize>false</Optimize>
22 <OutputPath>bin\Debug\</OutputPath>
22 <OutputPath>bin\Debug\</OutputPath>
23 <DefineConstants>DEBUG;TRACE</DefineConstants>
23 <DefineConstants>DEBUG;TRACE</DefineConstants>
24 <ErrorReport>prompt</ErrorReport>
24 <ErrorReport>prompt</ErrorReport>
25 <WarningLevel>4</WarningLevel>
25 <WarningLevel>4</WarningLevel>
26 </PropertyGroup>
26 </PropertyGroup>
27 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28 <PlatformTarget>AnyCPU</PlatformTarget>
28 <PlatformTarget>AnyCPU</PlatformTarget>
29 <DebugType>pdbonly</DebugType>
29 <DebugType>pdbonly</DebugType>
30 <Optimize>true</Optimize>
30 <Optimize>true</Optimize>
31 <OutputPath>bin\Release\</OutputPath>
31 <OutputPath>bin\Release\</OutputPath>
32 <DefineConstants>TRACE</DefineConstants>
32 <DefineConstants>TRACE</DefineConstants>
33 <ErrorReport>prompt</ErrorReport>
33 <ErrorReport>prompt</ErrorReport>
34 <WarningLevel>4</WarningLevel>
34 <WarningLevel>4</WarningLevel>
35 <Prefer32Bit>true</Prefer32Bit>
35 <Prefer32Bit>true</Prefer32Bit>
36 <DebugSymbols>true</DebugSymbols>
36 <DebugSymbols>true</DebugSymbols>
37 </PropertyGroup>
37 </PropertyGroup>
38 <ItemGroup>
38 <ItemGroup>
39 <Reference Include="System" />
39 <Reference Include="System" />
40 <Reference Include="System.Core" />
40 <Reference Include="System.Core" />
41 <Reference Include="System.Xml.Linq" />
41 <Reference Include="System.Xml.Linq" />
42 <Reference Include="System.Data.DataSetExtensions" />
42 <Reference Include="System.Data.DataSetExtensions" />
43 <Reference Include="Microsoft.CSharp" />
43 <Reference Include="Microsoft.CSharp" />
44 <Reference Include="System.Data" />
44 <Reference Include="System.Data" />
45 <Reference Include="System.Net.Http" />
45 <Reference Include="System.Net.Http" />
46 <Reference Include="System.Xml" />
46 <Reference Include="System.Xml" />
47 </ItemGroup>
47 </ItemGroup>
48 <ItemGroup>
48 <ItemGroup>
49 <Compile Include="Program.cs" />
49 <Compile Include="Program.cs" />
50 <Compile Include="Properties\AssemblyInfo.cs" />
50 <Compile Include="Properties\AssemblyInfo.cs" />
51 </ItemGroup>
51 </ItemGroup>
52 <ItemGroup>
52 <ItemGroup>
53 <None Include="App.config" />
53 <None Include="App.config" />
54 </ItemGroup>
54 </ItemGroup>
55 <ItemGroup>
55 <ItemGroup>
56 <ProjectReference Include="..\Implab\Implab.csproj">
56 <ProjectReference Include="..\Implab\Implab.csproj">
57 <Project>{f550f1f8-8746-4ad0-9614-855f4c4b7f05}</Project>
57 <Project>{f550f1f8-8746-4ad0-9614-855f4c4b7f05}</Project>
58 <Name>Implab</Name>
58 <Name>Implab</Name>
59 </ProjectReference>
59 </ProjectReference>
60 </ItemGroup>
60 </ItemGroup>
61 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
61 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
62 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
62 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
63 Other similar extension points exist, see Microsoft.Common.targets.
63 Other similar extension points exist, see Microsoft.Common.targets.
64 <Target Name="BeforeBuild">
64 <Target Name="BeforeBuild">
65 </Target>
65 </Target>
66 <Target Name="AfterBuild">
66 <Target Name="AfterBuild">
67 </Target>
67 </Target>
68 -->
68 -->
69 </Project> No newline at end of file
69 </Project>
@@ -1,92 +1,55
1 using Implab.Formats.Json;
1 using Implab.Diagnostics;
2 using Implab.Formats.Json;
2 using Implab.Parallels;
3 using Implab.Parallels;
3 using Implab.Xml;
4 using Implab.Xml;
4 using System;
5 using System;
5 using System.Collections.Concurrent;
6 using System.Collections.Concurrent;
6 using System.Collections.Generic;
7 using System.Collections.Generic;
7 using System.IO;
8 using System.IO;
8 using System.Linq;
9 using System.Linq;
9 using System.Text;
10 using System.Text;
10 using System.Threading;
11 using System.Threading;
11 using System.Threading.Tasks;
12 using System.Threading.Tasks;
12 using System.Xml;
13 using System.Xml;
13 using System.Xml.Serialization;
14 using System.Xml.Serialization;
14
15
15 namespace Implab.Playground {
16 namespace Implab.Playground {
17 using System.Diagnostics;
18 using System.Runtime.Remoting.Messaging;
19 using static Trace<Program>;
20
16 public class Program {
21 public class Program {
17
22
18 static void EnqueueRange<T>(ConcurrentQueue<T> q, T[] data, int offset, int len) {
23 static void Main(string[] args) {
19 for (var i = offset; i < offset + len; i++)
24 var listener = new SimpleTraceListener(Console.Out);
20 q.Enqueue(data[i]);
25
21 }
26 var source = Trace<Program>.TraceSource;
27 source.Switch.Level = SourceLevels.All;
22
28
23 static bool TryDequeueRange<T>(ConcurrentQueue<T> q,T[] buffer,int offset, int len, out int actual) {
29 source.Listeners.Add(listener);
24 actual = 0;
30
25 T res;
31 var t = Environment.TickCount;
26 while(q.TryDequeue(out res)) {
27 buffer[offset + actual] = res;
28 actual++;
29 if (actual == len)
30 break;
31 }
32 return actual != 0;
33 }
34
32
35 static void EnqueueRange<T>(SimpleAsyncQueue<T> q, T[] data, int offset, int len) {
33 Main().Wait();
36 for (var i = offset; i < offset + len; i++)
34
37 q.Enqueue(data[i]);
35 Console.WriteLine($"Done: {Environment.TickCount - t} ms");
36 Console.ReadKey();
38 }
37 }
39
38
40 static bool TryDequeueRange<T>(SimpleAsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
39 static async Task Main() {
41 actual = 0;
40 using (LogicalOperation(nameof(Main))) {
42 T res;
41 Log("Start");
43 while (q.TryDequeue(out res)) {
42 await SomeAsync();
44 buffer[offset + actual] = res;
43 Log("End");
45 actual++;
46 if (actual == len)
47 break;
48 }
49 return actual != 0;
50 }
51
52 static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
53 for (var i = offset; i < offset + len; i++)
54 q.Enqueue(data[i]);
55 }
56
57 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
58 actual = 0;
59 T res;
60 while (q.TryDequeue(out res)) {
61 buffer[offset + actual] = res;
62 actual++;
63 if (actual == len)
64 break;
65 }
66 return actual != 0;
67 }
68
69
70 /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
71 q.EnqueueRange(data, offset, len);
72 }
73
74 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
75 return q.TryDequeueRange(buffer, offset, len, out actual);
76 }*/
77
78
79 static void Main(string[] args) {
80
81 var t = Environment.TickCount;
82 using (var reader = JsonReader.Create("e:\\citylots.json")) {
83 while (reader.Read()) {
84 }
44 }
85 }
45 }
86
46
87 Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms");
47 static async Task SomeAsync() {
88
48 using (LogicalOperation(nameof(SomeAsync))) {
89 Console.WriteLine("done");
49 Log("Do prepare");
50 await Task.Yield();
51 Log("Yield");
90 }
52 }
91 }
53 }
92 }
54 }
55 }
@@ -1,16 +1,17
1 <Project Sdk="Microsoft.NET.Sdk">
1 <Project Sdk="Microsoft.NET.Sdk">
2
2
3 <PropertyGroup>
3 <PropertyGroup>
4 <TargetFramework>netcoreapp2.0</TargetFramework>
4 <TargetFramework>net46</TargetFramework>
5 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net45' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
5
6
6 <IsPackable>false</IsPackable>
7 <IsPackable>false</IsPackable>
7 </PropertyGroup>
8 </PropertyGroup>
8 <ItemGroup>
9 <ItemGroup>
9 <ProjectReference Include="../Implab/Implab.csproj"/>
10 <ProjectReference Include="../Implab/Implab.csproj" />
10 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
11 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
11 <PackageReference Include="xunit" Version="2.3.1" />
12 <PackageReference Include="xunit" Version="2.3.1" />
12 <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
13 <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
13 <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
14 <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
14 </ItemGroup>
15 </ItemGroup>
15
16
16 </Project>
17 </Project>
@@ -1,127 +1,132
1 using System;
1 using System;
2 using System.Collections.Generic;
2 using System.Collections.Generic;
3 using System.Diagnostics;
3 using System.Diagnostics;
4 using System.Linq;
4 using System.Linq;
5 using System.Text;
5 using System.Text;
6 using System.Threading;
6 using System.Threading.Tasks;
7 using System.Threading.Tasks;
7
8
8 namespace Implab.Diagnostics {
9 namespace Implab.Diagnostics {
9 public static class Trace<T> {
10 public static class Trace<T> {
10
11
11 readonly static TraceSource _traceSource = new TraceSource(typeof(T).Name);
12 public static TraceSource TraceSource { get; } = new TraceSource(typeof(T).Name);
12
13
13 public static TraceSource TraceSource {
14 #if NETFX_TRACE_BUG
14 get { return _traceSource; }
15 readonly static AsyncLocal<object> m_currentOperation = new AsyncLocal<object>();
15 }
16 #endif
16
17
17 /// <summary>
18 /// <summary>
18 /// Starts the logical operation nested to the current operation nested to the current one.
19 /// Starts the logical operation nested to the current operation nested to the current one.
19 /// </summary>
20 /// </summary>
20 [Conditional("TRACE")]
21 public static void StartLogicalOperation() {
21 public static void StartLogicalOperation() {
22 Trace.CorrelationManager.StartLogicalOperation();
22 Trace.CorrelationManager.StartLogicalOperation();
23
23
24 }
24 }
25
25
26 /// <summary>
26 /// <summary>
27 /// Starts the logical operation with the specified name, this name is usefull in logs.
27 /// Starts the logical operation with the specified name, this name is usefull in logs.
28 /// </summary>
28 /// </summary>
29 /// <param name="name">Name.</param>
29 /// <param name="name">Name.</param>
30 [Conditional("TRACE")]
30 #if NETFX_TRACE_BUG
31 public static void StartLogicalOperation(string name) {
31 public static void StartLogicalOperation(object name) {
32 m_currentOperation.Value = name;
32 Trace.CorrelationManager.StartLogicalOperation(name);
33 Trace.CorrelationManager.StartLogicalOperation(name);
33 }
34 }
35 #else
36 public static void StartLogicalOperation(object name) {
37 Trace.CorrelationManager.StartLogicalOperation(name);
38 }
39 #endif
34
40
35 /// <summary>
41 /// <summary>
36 /// Ends the logical operation and restores the previous one.
42 /// Ends the logical operation and restores the previous one.
37 /// </summary>
43 /// </summary>
38 [Conditional("TRACE")]
39 public static void StopLogicalOperation() {
44 public static void StopLogicalOperation() {
40 Trace.CorrelationManager.StopLogicalOperation();
45 Trace.CorrelationManager.StopLogicalOperation();
41 }
46 }
42
47
43 /// <summary>
48 /// <summary>
44 /// Writes an informational message.
49 /// Writes an informational message.
45 /// </summary>
50 /// </summary>
46 /// <param name="format">Format.</param>
51 /// <param name="format">Format.</param>
47 /// <param name="arguments">Arguments.</param>
52 /// <param name="arguments">Arguments.</param>
48 [Conditional("TRACE")]
53 [Conditional("TRACE")]
49 public static void Log(string format, params object[] arguments) {
54 public static void Log(string format, params object[] arguments) {
50 TraceSource.TraceEvent(TraceEventType.Information, 0, format, arguments);
55 TraceSource.TraceEvent(TraceEventType.Information, 0, format, arguments);
51 }
56 }
52
57
53 /// <summary>
58 /// <summary>
54 /// Writes a warning message.
59 /// Writes a warning message.
55 /// </summary>
60 /// </summary>
56 /// <param name="format">Format.</param>
61 /// <param name="format">Format.</param>
57 /// <param name="arguments">Arguments.</param>
62 /// <param name="arguments">Arguments.</param>
58 [Conditional("TRACE")]
63 [Conditional("TRACE")]
59 public static void Warn(string format, params object[] arguments) {
64 public static void Warn(string format, params object[] arguments) {
60 TraceSource.TraceEvent(TraceEventType.Warning, 0, format, arguments);
65 TraceSource.TraceEvent(TraceEventType.Warning, 0, format, arguments);
61 }
66 }
62
67
63 [Conditional("TRACE")]
68 [Conditional("TRACE")]
64 public static void Error(string format, params object[] arguments) {
69 public static void Error(string format, params object[] arguments) {
65 TraceSource.TraceEvent(TraceEventType.Error, 0, format, arguments);
70 TraceSource.TraceEvent(TraceEventType.Error, 0, format, arguments);
66 }
71 }
67
72
68 [Conditional("TRACE")]
73 [Conditional("TRACE")]
69 public static void Error(Exception err) {
74 public static void Error(Exception err) {
70 TraceSource.TraceData(TraceEventType.Error, 0, err);
75 TraceSource.TraceData(TraceEventType.Error, 0, err);
71 }
76 }
72
77
73 /// <summary>
78 /// <summary>
74 /// This method save the current activity, and transfers to the specified activity,
79 /// This method save the current activity, and transfers to the specified activity,
75 /// emits <see cref="TraceEventType.Start"/> and returns a scope of the new
80 /// emits <see cref="TraceEventType.Start"/> and returns a scope of the new
76 /// activity.
81 /// activity.
77 /// </summary>
82 /// </summary>
78 /// <param name="activityName">The name of the new activity/</param>
83 /// <param name="activityName">The name of the new activity/</param>
79 /// <param name="activityId">The identifier of the activity to which
84 /// <param name="activityId">The identifier of the activity to which
80 /// the control will be transferred</param>
85 /// the control will be transferred</param>
81 /// <returns>A scope of the new activity, dispose it to transfer
86 /// <returns>A scope of the new activity, dispose it to transfer
82 /// the control back to the original activity.</returns>
87 /// the control back to the original activity.</returns>
83 public static ActivityScope TransferActivity(string activityName, Guid activityId) {
88 public static ActivityScope TransferActivity(string activityName, Guid activityId) {
84 var prev = Trace.CorrelationManager.ActivityId;
89 var prev = Trace.CorrelationManager.ActivityId;
85
90
86 TraceSource.TraceTransfer(0, "Transfer", activityId);
91 TraceSource.TraceTransfer(0, "Transfer", activityId);
87 Trace.CorrelationManager.ActivityId = activityId;
92 Trace.CorrelationManager.ActivityId = activityId;
88 TraceSource.TraceEvent(TraceEventType.Start, 0, activityName);
93 TraceSource.TraceEvent(TraceEventType.Start, 0, activityName);
89
94
90 return new ActivityScope(TraceSource, prev, 0, activityName);
95 return new ActivityScope(TraceSource, prev, 0, activityName);
91 }
96 }
92
97
93 /// <summary>
98 /// <summary>
94 /// Emits <see cref="TraceEventType.Start"/> and returns a scope of the
99 /// Emits <see cref="TraceEventType.Start"/> and returns a scope of the
95 /// activity.
100 /// activity.
96 /// </summary>
101 /// </summary>
97 /// <param name="activityName">The name of the activity to start</param>
102 /// <param name="activityName">The name of the activity to start</param>
98 /// <returns>A scope of the new activity, dispose it to emit
103 /// <returns>A scope of the new activity, dispose it to emit
99 /// <see cref="TraceEventType.Stop"/> for the current activity.</returns>
104 /// <see cref="TraceEventType.Stop"/> for the current activity.</returns>
100 public static ActivityScope StartActivity(string activityName) {
105 public static ActivityScope StartActivity(string activityName) {
101 if (Trace.CorrelationManager.ActivityId == Guid.Empty)
106 if (Trace.CorrelationManager.ActivityId == Guid.Empty)
102 Trace.CorrelationManager.ActivityId = Guid.NewGuid();
107 Trace.CorrelationManager.ActivityId = Guid.NewGuid();
103
108
104 var prev = Trace.CorrelationManager.ActivityId;
109 var prev = Trace.CorrelationManager.ActivityId;
105
110
106 TraceSource.TraceEvent(TraceEventType.Start, 0, activityName);
111 TraceSource.TraceEvent(TraceEventType.Start, 0, activityName);
107 return new ActivityScope(TraceSource, prev, 0, activityName);
112 return new ActivityScope(TraceSource, prev, 0, activityName);
108 }
113 }
109
114
110 /// <summary>
115 /// <summary>
111 /// Creates new <see cref="LogicalOperation(string)"/> and calls
116 /// Creates new <see cref="LogicalOperation(string)"/> and calls
112 /// to <see cref="CorrelationManager.StartLogicalOperation(object)"/>
117 /// to <see cref="CorrelationManager.StartLogicalOperation(object)"/>
113 /// passing the created operation as identity. Calls
118 /// passing the created operation as identity. Calls
114 /// <see cref="TraceSource.TraceData(TraceEventType, int, object)"/>
119 /// <see cref="TraceSource.TraceData(TraceEventType, int, object)"/>
115 /// to notify listeners on operation start.
120 /// to notify listeners on operation start.
116 /// </summary>
121 /// </summary>
117 /// <param name="name">The name of the logical operation.</param>
122 /// <param name="name">The name of the logical operation.</param>
118 /// <returns>Logical operation scope, disposing it will stop
123 /// <returns>Logical operation scope, disposing it will stop
119 /// logical operation and notify trace listeners.</returns>
124 /// logical operation and notify trace listeners.</returns>
120 public static LogicalOperationScope LogicalOperation(string name) {
125 public static LogicalOperationScope LogicalOperation(string name) {
121 var operation = new LogicalOperation(name);
126 var operation = new LogicalOperation(name);
122 TraceSource.TraceData(TraceEventType.Information, TraceEventCodes.StartLogicalOperation, operation);
127 TraceSource.TraceData(TraceEventType.Information, TraceEventCodes.StartLogicalOperation, operation);
123 Trace.CorrelationManager.StartLogicalOperation(operation);
128 StartLogicalOperation(operation);
124 return new LogicalOperationScope(TraceSource, operation);
129 return new LogicalOperationScope(TraceSource, operation);
125 }
130 }
126 }
131 }
127 }
132 }
@@ -1,18 +1,19
1 <Project Sdk="Microsoft.NET.Sdk">
1 <Project Sdk="Microsoft.NET.Sdk">
2
2
3 <PropertyGroup>
3 <PropertyGroup>
4 <Authors>Sergey Smirnov</Authors>
4 <Authors>Sergey Smirnov</Authors>
5 <Title>Implab library</Title>
5 <Title>Implab library</Title>
6 <Description>Provides some helper clesses like XML serialization helpers, JSON XML reader,
6 <Description>Provides some helper clesses like XML serialization helpers, JSON XML reader,
7 JSON pull-parser, ECMA-style promises, lightweight synchonization routines Signal
7 JSON pull-parser, ECMA-style promises, lightweight synchonization routines Signal
8 and SharedLock, Trace helpers on top of System.Diagnostics, ObjectPool etc.
8 and SharedLock, Trace helpers on top of System.Diagnostics, ObjectPool etc.
9 </Description>
9 </Description>
10 <Copyright>2012-2018 Sergey Smirnov</Copyright>
10 <Copyright>2012-2018 Sergey Smirnov</Copyright>
11 <LicenseUrl>https://opensource.org/licenses/BSD-2-Clause</LicenseUrl>
11 <LicenseUrl>https://opensource.org/licenses/BSD-2-Clause</LicenseUrl>
12 <ProjectUrl>https://implab.org</ProjectUrl>
12 <ProjectUrl>https://implab.org</ProjectUrl>
13 <RepositoryUrl>https://hg.implab.org/pub/ImplabNet/</RepositoryUrl>
13 <RepositoryUrl>https://hg.implab.org/pub/ImplabNet/</RepositoryUrl>
14 <TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
14 <TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
15 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net45' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
15 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net46' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
16 <DefineConstants Condition="'$(TargetFramework)'=='net46'">NETFX_TRACE_BUG;$(DefineConstants)</DefineConstants>
16 </PropertyGroup>
17 </PropertyGroup>
17
18
18 </Project>
19 </Project>
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now