##// END OF EJS Templates
initial work on interactive logger
cin -
r45:d10034588e38 interactive logger
parent child
Show More
@@ -0,0 +1,83
1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="4.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')" />
4 <PropertyGroup>
5 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 <ProjectGuid>{1DB7DB0C-8AA9-484B-A681-33AE94038391}</ProjectGuid>
8 <OutputType>Library</OutputType>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <RootNamespace>Implab.Diagnostics.Interactive</RootNamespace>
11 <AssemblyName>Implab.Diagnostics.Interactive</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 <FileAlignment>512</FileAlignment>
14 </PropertyGroup>
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16 <DebugSymbols>true</DebugSymbols>
17 <DebugType>full</DebugType>
18 <Optimize>false</Optimize>
19 <OutputPath>bin\Debug\</OutputPath>
20 <DefineConstants>DEBUG;TRACE</DefineConstants>
21 <ErrorReport>prompt</ErrorReport>
22 <WarningLevel>4</WarningLevel>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <DebugType>pdbonly</DebugType>
26 <Optimize>true</Optimize>
27 <OutputPath>bin\Release\</OutputPath>
28 <DefineConstants>TRACE</DefineConstants>
29 <ErrorReport>prompt</ErrorReport>
30 <WarningLevel>4</WarningLevel>
31 </PropertyGroup>
32 <ItemGroup>
33 <Reference Include="System" />
34 <Reference Include="System.Core" />
35 <Reference Include="System.Drawing" />
36 <Reference Include="System.Windows.Forms" />
37 <Reference Include="System.Xml.Linq" />
38 <Reference Include="System.Data.DataSetExtensions" />
39 <Reference Include="Microsoft.CSharp" />
40 <Reference Include="System.Data" />
41 <Reference Include="System.Xml" />
42 </ItemGroup>
43 <ItemGroup>
44 <Compile Include="InteractiveTracer.cs" />
45 <Compile Include="Properties\AssemblyInfo.cs" />
46 <Compile Include="TextStyle.cs" />
47 <Compile Include="TraceForm.cs">
48 <SubType>Form</SubType>
49 </Compile>
50 <Compile Include="TraceForm.Designer.cs">
51 <DependentUpon>TraceForm.cs</DependentUpon>
52 </Compile>
53 <Compile Include="TraceViewControl.cs">
54 <SubType>UserControl</SubType>
55 </Compile>
56 <Compile Include="TraceViewControl.Designer.cs">
57 <DependentUpon>TraceViewControl.cs</DependentUpon>
58 </Compile>
59 <Compile Include="TraceViewItem.cs" />
60 </ItemGroup>
61 <ItemGroup>
62 <ProjectReference Include="..\external\Implab\Implab.csproj">
63 <Project>{f550f1f8-8746-4ad0-9614-855f4c4b7f05}</Project>
64 <Name>Implab</Name>
65 </ProjectReference>
66 </ItemGroup>
67 <ItemGroup>
68 <EmbeddedResource Include="TraceForm.resx">
69 <DependentUpon>TraceForm.cs</DependentUpon>
70 </EmbeddedResource>
71 <EmbeddedResource Include="TraceViewControl.resx">
72 <DependentUpon>TraceViewControl.cs</DependentUpon>
73 </EmbeddedResource>
74 </ItemGroup>
75 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
76 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
77 Other similar extension points exist, see Microsoft.Common.targets.
78 <Target Name="BeforeBuild">
79 </Target>
80 <Target Name="AfterBuild">
81 </Target>
82 -->
83 </Project> No newline at end of file
@@ -0,0 +1,55
1 using Implab.Parallels;
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using System.Threading;
7 using System.Threading.Tasks;
8 using System.Windows.Forms;
9
10 namespace Implab.Diagnostics.Interactive
11 {
12 public class InteractiveTracer: Disposable
13 {
14 TraceForm m_form;
15 SynchronizationContext m_syncGuiThread;
16 readonly IPromiseBase m_completed;
17 readonly Promise<object> m_started = new Promise<object>();
18
19 public InteractiveTracer() {
20 m_completed = AsyncPool.InvokeNewThread(() => {
21 GuiThread();
22 return 0;
23 });
24
25 m_started.Join();
26 }
27
28 void GuiThread() {
29 m_form = new TraceForm(); // will create SynchronizationContext
30 m_syncGuiThread = SynchronizationContext.Current;
31 m_started.Resolve();
32 Application.Run();
33 }
34
35 public void ShowForm() {
36 m_syncGuiThread.Post(x => m_form.Show(), null);
37 }
38
39 public void HideForm() {
40 m_syncGuiThread.Post(x => m_form.Hide(), null);
41 }
42
43 void Terminate() {
44 m_syncGuiThread.Post(x => Application.ExitThread(), null);
45 }
46
47 protected override void Dispose(bool disposing) {
48 if (disposing) {
49 Terminate();
50 m_completed.Join();
51 }
52 base.Dispose(disposing);
53 }
54 }
55 }
@@ -0,0 +1,36
1 using System.Reflection;
2 using System.Runtime.CompilerServices;
3 using System.Runtime.InteropServices;
4
5 // General Information about an assembly is controlled through the following
6 // set of attributes. Change these attribute values to modify the information
7 // associated with an assembly.
8 [assembly: AssemblyTitle("Implab.Diagnostics.Interactive")]
9 [assembly: AssemblyDescription("")]
10 [assembly: AssemblyConfiguration("")]
11 [assembly: AssemblyCompany("")]
12 [assembly: AssemblyProduct("Implab.Diagnostics.Interactive")]
13 [assembly: AssemblyCopyright("Copyright © 2014")]
14 [assembly: AssemblyTrademark("")]
15 [assembly: AssemblyCulture("")]
16
17 // Setting ComVisible to false makes the types in this assembly not visible
18 // to COM components. If you need to access a type in this assembly from
19 // COM, set the ComVisible attribute to true on that type.
20 [assembly: ComVisible(false)]
21
22 // The following GUID is for the ID of the typelib if this project is exposed to COM
23 [assembly: Guid("1c156c51-4884-43b2-a823-d86313872e82")]
24
25 // Version information for an assembly consists of the following four values:
26 //
27 // Major Version
28 // Minor Version
29 // Build Number
30 // Revision
31 //
32 // You can specify all the values or you can default the Build and Revision Numbers
33 // by using the '*' as shown below:
34 // [assembly: AssemblyVersion("1.0.*")]
35 [assembly: AssemblyVersion("1.0.0.0")]
36 [assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,25
1 using System;
2 using System.Collections.Generic;
3 using System.Drawing;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7
8 namespace Implab.Diagnostics.Interactive {
9 class TextStyle {
10 public Color TextColor {
11 get;
12 set;
13 }
14
15 public FontStyle FontStyle {
16 get;
17 set;
18 }
19
20 public int PaddingLeft {
21 get;
22 set;
23 }
24 }
25 }
@@ -0,0 +1,52
1 namespace Implab.Diagnostics.Interactive {
2 partial class TraceForm {
3 /// <summary>
4 /// Required designer variable.
5 /// </summary>
6 private System.ComponentModel.IContainer components = null;
7
8 /// <summary>
9 /// Clean up any resources being used.
10 /// </summary>
11 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
12 protected override void Dispose(bool disposing) {
13 if (disposing && (components != null)) {
14 components.Dispose();
15 }
16 base.Dispose(disposing);
17 }
18
19 #region Windows Form Designer generated code
20
21 /// <summary>
22 /// Required method for Designer support - do not modify
23 /// the contents of this method with the code editor.
24 /// </summary>
25 private void InitializeComponent() {
26 this.traceViewControl1 = new Implab.Diagnostics.Interactive.TraceViewControl();
27 this.SuspendLayout();
28 //
29 // traceViewControl1
30 //
31 this.traceViewControl1.Location = new System.Drawing.Point(13, 13);
32 this.traceViewControl1.Name = "traceViewControl1";
33 this.traceViewControl1.Size = new System.Drawing.Size(267, 248);
34 this.traceViewControl1.TabIndex = 0;
35 //
36 // TraceForm
37 //
38 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
39 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
40 this.ClientSize = new System.Drawing.Size(292, 273);
41 this.Controls.Add(this.traceViewControl1);
42 this.Name = "TraceForm";
43 this.Text = "TraceForm";
44 this.ResumeLayout(false);
45
46 }
47
48 #endregion
49
50 private TraceViewControl traceViewControl1;
51 }
52 } No newline at end of file
@@ -0,0 +1,25
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10
11 namespace Implab.Diagnostics.Interactive {
12 public partial class TraceForm : Form {
13 public TraceForm() {
14 InitializeComponent();
15 }
16
17 protected override void OnFormClosing(FormClosingEventArgs e) {
18 base.OnFormClosing(e);
19 if (!e.Cancel && e.CloseReason == CloseReason.UserClosing) {
20 e.Cancel = true;
21 Hide();
22 }
23 }
24 }
25 }
@@ -0,0 +1,120
1 <?xml version="1.0" encoding="utf-8"?>
2 <root>
3 <!--
4 Microsoft ResX Schema
5
6 Version 2.0
7
8 The primary goals of this format is to allow a simple XML format
9 that is mostly human readable. The generation and parsing of the
10 various data types are done through the TypeConverter classes
11 associated with the data types.
12
13 Example:
14
15 ... ado.net/XML headers & schema ...
16 <resheader name="resmimetype">text/microsoft-resx</resheader>
17 <resheader name="version">2.0</resheader>
18 <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19 <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20 <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21 <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22 <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23 <value>[base64 mime encoded serialized .NET Framework object]</value>
24 </data>
25 <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26 <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27 <comment>This is a comment</comment>
28 </data>
29
30 There are any number of "resheader" rows that contain simple
31 name/value pairs.
32
33 Each data row contains a name, and value. The row also contains a
34 type or mimetype. Type corresponds to a .NET class that support
35 text/value conversion through the TypeConverter architecture.
36 Classes that don't support this are serialized and stored with the
37 mimetype set.
38
39 The mimetype is used for serialized objects, and tells the
40 ResXResourceReader how to depersist the object. This is currently not
41 extensible. For a given mimetype the value must be set accordingly:
42
43 Note - application/x-microsoft.net.object.binary.base64 is the format
44 that the ResXResourceWriter will generate, however the reader can
45 read any of the formats listed below.
46
47 mimetype: application/x-microsoft.net.object.binary.base64
48 value : The object must be serialized with
49 : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50 : and then encoded with base64 encoding.
51
52 mimetype: application/x-microsoft.net.object.soap.base64
53 value : The object must be serialized with
54 : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55 : and then encoded with base64 encoding.
56
57 mimetype: application/x-microsoft.net.object.bytearray.base64
58 value : The object must be serialized into a byte array
59 : using a System.ComponentModel.TypeConverter
60 : and then encoded with base64 encoding.
61 -->
62 <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63 <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64 <xsd:element name="root" msdata:IsDataSet="true">
65 <xsd:complexType>
66 <xsd:choice maxOccurs="unbounded">
67 <xsd:element name="metadata">
68 <xsd:complexType>
69 <xsd:sequence>
70 <xsd:element name="value" type="xsd:string" minOccurs="0" />
71 </xsd:sequence>
72 <xsd:attribute name="name" use="required" type="xsd:string" />
73 <xsd:attribute name="type" type="xsd:string" />
74 <xsd:attribute name="mimetype" type="xsd:string" />
75 <xsd:attribute ref="xml:space" />
76 </xsd:complexType>
77 </xsd:element>
78 <xsd:element name="assembly">
79 <xsd:complexType>
80 <xsd:attribute name="alias" type="xsd:string" />
81 <xsd:attribute name="name" type="xsd:string" />
82 </xsd:complexType>
83 </xsd:element>
84 <xsd:element name="data">
85 <xsd:complexType>
86 <xsd:sequence>
87 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89 </xsd:sequence>
90 <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91 <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92 <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93 <xsd:attribute ref="xml:space" />
94 </xsd:complexType>
95 </xsd:element>
96 <xsd:element name="resheader">
97 <xsd:complexType>
98 <xsd:sequence>
99 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100 </xsd:sequence>
101 <xsd:attribute name="name" type="xsd:string" use="required" />
102 </xsd:complexType>
103 </xsd:element>
104 </xsd:choice>
105 </xsd:complexType>
106 </xsd:element>
107 </xsd:schema>
108 <resheader name="resmimetype">
109 <value>text/microsoft-resx</value>
110 </resheader>
111 <resheader name="version">
112 <value>2.0</value>
113 </resheader>
114 <resheader name="reader">
115 <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116 </resheader>
117 <resheader name="writer">
118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119 </resheader>
120 </root> No newline at end of file
@@ -0,0 +1,40
1 namespace Implab.Diagnostics.Interactive {
2 partial class TraceViewControl {
3 /// <summary>
4 /// Required designer variable.
5 /// </summary>
6 private System.ComponentModel.IContainer components = null;
7
8 /// <summary>
9 /// Clean up any resources being used.
10 /// </summary>
11 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
12 protected override void Dispose(bool disposing) {
13 if (disposing && (components != null)) {
14 components.Dispose();
15 }
16 base.Dispose(disposing);
17 }
18
19 #region Component Designer generated code
20
21 /// <summary>
22 /// Required method for Designer support - do not modify
23 /// the contents of this method with the code editor.
24 /// </summary>
25 private void InitializeComponent() {
26 this.SuspendLayout();
27 //
28 // TraceViewControl
29 //
30 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
31 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
32 this.BackColor = System.Drawing.SystemColors.Window;
33 this.Name = "TraceViewControl";
34 this.ResumeLayout(false);
35
36 }
37
38 #endregion
39 }
40 }
@@ -0,0 +1,55
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Data;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10
11 namespace Implab.Diagnostics.Interactive {
12 public partial class TraceViewControl : UserControl {
13 int m_maxEvents = 1000;
14
15 string m_status = "ready";
16
17 readonly LinkedList<TraceViewItem> m_events = new LinkedList<TraceViewItem>();
18 public TraceViewControl() {
19 InitializeComponent();
20
21 var ticks = Environment.TickCount;
22
23 for (int i = 0; i < 1333; i++) {
24 AddViewItem(new TraceViewItem {
25 indent = i % 4,
26 message = String.Format("Auto generated {0}", i),
27 thread = 2,
28 timestamp = ticks + i*10
29 });
30 }
31 }
32
33 public void AddViewItem(TraceViewItem item) {
34 m_events.AddLast(item);
35 if (m_events.Count > m_maxEvents)
36 m_events.RemoveFirst();
37 }
38
39 protected override void OnPaint(PaintEventArgs e) {
40 base.OnPaint(e);
41
42 if (m_status != null)
43 e.Graphics.DrawString(m_status, DefaultFont, Brushes.Black, 0, 0);
44
45 }
46
47 protected override void OnMouseMove(MouseEventArgs e) {
48 base.OnMouseMove(e);
49
50 m_status = String.Format("({0},{1})", e.X, e.Y);
51 Invalidate();
52 }
53
54 }
55 }
@@ -0,0 +1,120
1 <?xml version="1.0" encoding="utf-8"?>
2 <root>
3 <!--
4 Microsoft ResX Schema
5
6 Version 2.0
7
8 The primary goals of this format is to allow a simple XML format
9 that is mostly human readable. The generation and parsing of the
10 various data types are done through the TypeConverter classes
11 associated with the data types.
12
13 Example:
14
15 ... ado.net/XML headers & schema ...
16 <resheader name="resmimetype">text/microsoft-resx</resheader>
17 <resheader name="version">2.0</resheader>
18 <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19 <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20 <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21 <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22 <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23 <value>[base64 mime encoded serialized .NET Framework object]</value>
24 </data>
25 <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26 <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27 <comment>This is a comment</comment>
28 </data>
29
30 There are any number of "resheader" rows that contain simple
31 name/value pairs.
32
33 Each data row contains a name, and value. The row also contains a
34 type or mimetype. Type corresponds to a .NET class that support
35 text/value conversion through the TypeConverter architecture.
36 Classes that don't support this are serialized and stored with the
37 mimetype set.
38
39 The mimetype is used for serialized objects, and tells the
40 ResXResourceReader how to depersist the object. This is currently not
41 extensible. For a given mimetype the value must be set accordingly:
42
43 Note - application/x-microsoft.net.object.binary.base64 is the format
44 that the ResXResourceWriter will generate, however the reader can
45 read any of the formats listed below.
46
47 mimetype: application/x-microsoft.net.object.binary.base64
48 value : The object must be serialized with
49 : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50 : and then encoded with base64 encoding.
51
52 mimetype: application/x-microsoft.net.object.soap.base64
53 value : The object must be serialized with
54 : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55 : and then encoded with base64 encoding.
56
57 mimetype: application/x-microsoft.net.object.bytearray.base64
58 value : The object must be serialized into a byte array
59 : using a System.ComponentModel.TypeConverter
60 : and then encoded with base64 encoding.
61 -->
62 <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63 <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64 <xsd:element name="root" msdata:IsDataSet="true">
65 <xsd:complexType>
66 <xsd:choice maxOccurs="unbounded">
67 <xsd:element name="metadata">
68 <xsd:complexType>
69 <xsd:sequence>
70 <xsd:element name="value" type="xsd:string" minOccurs="0" />
71 </xsd:sequence>
72 <xsd:attribute name="name" use="required" type="xsd:string" />
73 <xsd:attribute name="type" type="xsd:string" />
74 <xsd:attribute name="mimetype" type="xsd:string" />
75 <xsd:attribute ref="xml:space" />
76 </xsd:complexType>
77 </xsd:element>
78 <xsd:element name="assembly">
79 <xsd:complexType>
80 <xsd:attribute name="alias" type="xsd:string" />
81 <xsd:attribute name="name" type="xsd:string" />
82 </xsd:complexType>
83 </xsd:element>
84 <xsd:element name="data">
85 <xsd:complexType>
86 <xsd:sequence>
87 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89 </xsd:sequence>
90 <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91 <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92 <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93 <xsd:attribute ref="xml:space" />
94 </xsd:complexType>
95 </xsd:element>
96 <xsd:element name="resheader">
97 <xsd:complexType>
98 <xsd:sequence>
99 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100 </xsd:sequence>
101 <xsd:attribute name="name" type="xsd:string" use="required" />
102 </xsd:complexType>
103 </xsd:element>
104 </xsd:choice>
105 </xsd:complexType>
106 </xsd:element>
107 </xsd:schema>
108 <resheader name="resmimetype">
109 <value>text/microsoft-resx</value>
110 </resheader>
111 <resheader name="version">
112 <value>2.0</value>
113 </resheader>
114 <resheader name="reader">
115 <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116 </resheader>
117 <resheader name="writer">
118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119 </resheader>
120 </root> No newline at end of file
@@ -0,0 +1,14
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace Implab.Diagnostics.Interactive {
8 public struct TraceViewItem {
9 public string message;
10 public int timestamp;
11 public int indent;
12 public int thread;
13 }
14 }
@@ -1,13 +1,15
1 1 syntax: glob
2 2 Implab.Test/bin/
3 3 *.user
4 4 Implab.Test/obj/
5 5 *.userprefs
6 6 Implab/bin/
7 7 Implab/obj/
8 8 TestResults/
9 9 Implab.Fx/obj/
10 10 Implab.Fx/bin/
11 11 Implab.Fx.Test/bin/
12 12 Implab.Fx.Test/obj/
13 13 _ReSharper.Implab/
14 Implab.Diagnostics.Interactive/bin/
15 Implab.Diagnostics.Interactive/obj/
@@ -1,71 +1,70
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3 <PropertyGroup>
4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 6 <ProductVersion>10.0.0</ProductVersion>
7 7 <SchemaVersion>2.0</SchemaVersion>
8 8 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
9 9 <OutputType>Library</OutputType>
10 10 <RootNamespace>Implab</RootNamespace>
11 11 <AssemblyName>Implab</AssemblyName>
12 12 </PropertyGroup>
13 13 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14 14 <DebugSymbols>true</DebugSymbols>
15 15 <DebugType>full</DebugType>
16 16 <Optimize>false</Optimize>
17 17 <OutputPath>bin\Debug</OutputPath>
18 18 <DefineConstants>TRACE;DEBUG;</DefineConstants>
19 19 <ErrorReport>prompt</ErrorReport>
20 20 <WarningLevel>4</WarningLevel>
21 21 <ConsolePause>false</ConsolePause>
22 22 </PropertyGroup>
23 23 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24 24 <DebugType>full</DebugType>
25 25 <Optimize>true</Optimize>
26 26 <OutputPath>bin\Release</OutputPath>
27 27 <ErrorReport>prompt</ErrorReport>
28 28 <WarningLevel>4</WarningLevel>
29 29 <ConsolePause>false</ConsolePause>
30 30 </PropertyGroup>
31 31 <ItemGroup>
32 32 <Reference Include="System" />
33 33 </ItemGroup>
34 34 <ItemGroup>
35 35 <Compile Include="Component.cs" />
36 36 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
37 37 <Compile Include="Diagnostics\EventText.cs" />
38 38 <Compile Include="Diagnostics\IEventTextFormatter.cs" />
39 39 <Compile Include="Diagnostics\LogChannel.cs" />
40 40 <Compile Include="Diagnostics\LogicalOperation.cs" />
41 41 <Compile Include="Diagnostics\TextFileListener.cs" />
42 42 <Compile Include="Diagnostics\TextListenerBase.cs" />
43 43 <Compile Include="Diagnostics\TraceLog.cs" />
44 44 <Compile Include="Diagnostics\TraceContext.cs" />
45 45 <Compile Include="Diagnostics\TraceEvent.cs" />
46 46 <Compile Include="Diagnostics\TraceEventType.cs" />
47 47 <Compile Include="Disposable.cs" />
48 48 <Compile Include="ICancellable.cs" />
49 49 <Compile Include="IProgressHandler.cs" />
50 50 <Compile Include="IProgressNotifier.cs" />
51 51 <Compile Include="IPromise.cs" />
52 52 <Compile Include="IPromiseBase.cs" />
53 53 <Compile Include="IServiceLocator.cs" />
54 54 <Compile Include="ITaskController.cs" />
55 <Compile Include="ManagedPromise.cs" />
56 55 <Compile Include="Parallels\DispatchPool.cs" />
57 56 <Compile Include="Parallels\ArrayTraits.cs" />
58 57 <Compile Include="Parallels\MTQueue.cs" />
59 58 <Compile Include="Parallels\WorkerPool.cs" />
60 59 <Compile Include="ServiceLocator.cs" />
61 60 <Compile Include="TaskController.cs" />
62 61 <Compile Include="ProgressInitEventArgs.cs" />
63 62 <Compile Include="Properties\AssemblyInfo.cs" />
64 63 <Compile Include="Promise.cs" />
65 64 <Compile Include="Parallels\AsyncPool.cs" />
66 65 <Compile Include="Safe.cs" />
67 66 <Compile Include="ValueEventArgs.cs" />
68 67 </ItemGroup>
69 68 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
70 69 <ItemGroup />
71 70 </Project> No newline at end of file
@@ -1,50 +1,50
1 1 using Implab.Diagnostics;
2 2 using System;
3 3 using System.Threading;
4 4
5 5 namespace Implab.Parallels {
6 6 /// <summary>
7 7 /// Класс для распаралеливания задач.
8 8 /// </summary>
9 9 /// <remarks>
10 10 /// Используя данный класс и лямда выражения можно распараллелить
11 11 /// вычисления, для этого используется концепция обещаний.
12 12 /// </remarks>
13 13 public static class AsyncPool {
14 14
15 public static Promise<T> Invoke<T>(Func<T> func) {
15 public static IPromise<T> Invoke<T>(Func<T> func) {
16 16 var p = new Promise<T>();
17 17 var caller = TraceContext.Snapshot();
18 18
19 19 ThreadPool.QueueUserWorkItem(param => {
20 20 TraceContext.Transfer(caller);
21 21 try {
22 22 p.Resolve(func());
23 23 } catch(Exception e) {
24 24 p.Reject(e);
25 25 }
26 26 });
27 27
28 28 return p;
29 29 }
30 30
31 public static Promise<T> InvokeNewThread<T>(Func<T> func) {
31 public static IPromise<T> InvokeNewThread<T>(Func<T> func) {
32 32 var p = new Promise<T>();
33 33
34 34 var caller = TraceContext.Snapshot();
35 35
36 36 var worker = new Thread(() => {
37 37 TraceContext.Transfer(caller);
38 38 try {
39 39 p.Resolve(func());
40 40 } catch (Exception e) {
41 41 p.Reject(e);
42 42 }
43 43 });
44 44 worker.IsBackground = true;
45 45 worker.Start();
46 46
47 47 return p;
48 48 }
49 49 }
50 50 }
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now