Auto status change to "Under Review"
@@ -0,0 +1,18 | |||
|
1 | using System.Threading; | |
|
2 | using System; | |
|
3 | ||
|
4 | namespace Implab { | |
|
5 | public class SyncContextPromise<T> : Promise<T> { | |
|
6 | readonly SynchronizationContext m_context; | |
|
7 | ||
|
8 | public SyncContextPromise(SynchronizationContext context) { | |
|
9 | Safe.ArgumentNotNull(context, "context"); | |
|
10 | m_context = context; | |
|
11 | } | |
|
12 | ||
|
13 | protected override void SignalHandler(HandlerDescriptor handler, int signal) { | |
|
14 | m_context.Post(x => base.SignalHandler(handler, signal), null); | |
|
15 | } | |
|
16 | } | |
|
17 | } | |
|
18 |
@@ -1,188 +1,204 | |||
|
1 | 1 | using Implab.Components; |
|
2 | 2 | using Implab.Diagnostics; |
|
3 | 3 | using Implab.Parallels; |
|
4 | 4 | using System; |
|
5 | 5 | using System.Collections.Generic; |
|
6 | 6 | using System.Linq; |
|
7 | 7 | using System.Text; |
|
8 | 8 | using System.Threading; |
|
9 | 9 | using System.Threading.Tasks; |
|
10 | 10 | using System.Windows.Forms; |
|
11 | 11 | |
|
12 | 12 | namespace Implab.Fx { |
|
13 | 13 | public class StaApartment : RunnableComponent { |
|
14 | 14 | readonly Thread m_worker; |
|
15 | 15 | SynchronizationContext m_syncContext; |
|
16 | SyncContextPromise m_enterPromise; | |
|
17 | ||
|
16 | 18 | readonly Promise m_threadStarted; |
|
17 | 19 | readonly Promise m_threadTerminated; |
|
18 | 20 | |
|
19 | 21 | public StaApartment() : base(true) { |
|
20 | 22 | m_threadStarted = new Promise(); |
|
21 | 23 | m_threadTerminated = new Promise(); |
|
22 | 24 | |
|
23 | 25 | m_worker = new Thread(WorkerEntry); |
|
24 | 26 | m_worker.SetApartmentState(ApartmentState.STA); |
|
25 | 27 | m_worker.IsBackground = true; |
|
26 | 28 | m_worker.Name = "STA managed aparment"; |
|
27 | 29 | } |
|
28 | 30 | |
|
29 | 31 | public SynchronizationContext SyncContext { |
|
30 | 32 | get { |
|
31 | 33 | if (m_syncContext == null) |
|
32 | 34 | throw new InvalidOperationException(); |
|
33 | 35 | return m_syncContext; |
|
34 | 36 | } |
|
35 | 37 | } |
|
36 | 38 | |
|
39 | /// <summary> | |
|
40 | /// Returns the promise which will dispatch all handlers inside the apartment using it's <see cref="SynchronizationContext"/> | |
|
41 | /// </summary> | |
|
42 | /// <remarks> | |
|
43 | /// Current implementation is optimized and will lost aync operation stack | |
|
44 | /// </remarks> | |
|
45 | /// <returns>The promise</returns> | |
|
46 | public IPromise Enter() { | |
|
47 | if (m_enterPromise == null) | |
|
48 | throw new InvalidOperationException(); | |
|
49 | return m_enterPromise; | |
|
50 | } | |
|
51 | ||
|
37 | 52 | public IPromise Invoke(Action<ICancellationToken> action) { |
|
38 | 53 | Safe.ArgumentNotNull(action, "action"); |
|
39 | 54 | |
|
40 | 55 | if (m_syncContext == null) |
|
41 | 56 | throw new InvalidOperationException(); |
|
42 | 57 | var p = new Promise(); |
|
43 | 58 | var lop = TraceContext.Instance.CurrentOperation; |
|
44 | 59 | |
|
45 | 60 | m_syncContext.Post(x => { |
|
46 | 61 | TraceContext.Instance.EnterLogicalOperation(lop, false); |
|
47 | 62 | try { |
|
48 | 63 | if (p.CancelOperationIfRequested()) |
|
49 | 64 | return; |
|
50 | 65 | |
|
51 | 66 | action(p); |
|
52 | 67 | p.Resolve(); |
|
53 | 68 | } catch (Exception e) { |
|
54 | 69 | p.Reject(e); |
|
55 | 70 | } finally { |
|
56 | 71 | TraceContext.Instance.Leave(); |
|
57 | 72 | } |
|
58 | 73 | }, null); |
|
59 | 74 | |
|
60 | 75 | return p; |
|
61 | 76 | } |
|
62 | 77 | |
|
63 | 78 | public IPromise<T> Invoke<T>(Func<ICancellationToken, T> action) { |
|
64 | 79 | Safe.ArgumentNotNull(action, "action"); |
|
65 | 80 | |
|
66 | 81 | if (m_syncContext == null) |
|
67 | 82 | throw new InvalidOperationException(); |
|
68 | 83 | var p = new Promise<T>(); |
|
69 | 84 | var lop = TraceContext.Instance.CurrentOperation; |
|
70 | 85 | |
|
71 | 86 | m_syncContext.Post(x => { |
|
72 | 87 | TraceContext.Instance.EnterLogicalOperation(lop, false); |
|
73 | 88 | try { |
|
74 | 89 | if (p.CancelOperationIfRequested()) |
|
75 | 90 | return; |
|
76 | 91 | p.Resolve(action(p)); |
|
77 | 92 | } catch (Exception e) { |
|
78 | 93 | p.Reject(e); |
|
79 | 94 | } finally { |
|
80 | 95 | TraceContext.Instance.Leave(); |
|
81 | 96 | } |
|
82 | 97 | }, null); |
|
83 | 98 | |
|
84 | 99 | return p; |
|
85 | 100 | } |
|
86 | 101 | |
|
87 | 102 | public IPromise Invoke(Action action) { |
|
88 | 103 | Safe.ArgumentNotNull(action, "action"); |
|
89 | 104 | |
|
90 | 105 | if (m_syncContext == null) |
|
91 | 106 | throw new InvalidOperationException(); |
|
92 | 107 | var p = new Promise(); |
|
93 | 108 | var lop = TraceContext.Instance.CurrentOperation; |
|
94 | 109 | |
|
95 | 110 | m_syncContext.Post(x => { |
|
96 | 111 | TraceContext.Instance.EnterLogicalOperation(lop, false); |
|
97 | 112 | try { |
|
98 | 113 | if (p.CancelOperationIfRequested()) |
|
99 | 114 | return; |
|
100 | 115 | action(); |
|
101 | 116 | p.Resolve(); |
|
102 | 117 | } catch (Exception e) { |
|
103 | 118 | p.Reject(e); |
|
104 | 119 | } finally { |
|
105 | 120 | TraceContext.Instance.Leave(); |
|
106 | 121 | } |
|
107 | 122 | }, null); |
|
108 | 123 | |
|
109 | 124 | return p; |
|
110 | 125 | } |
|
111 | 126 | |
|
112 | 127 | public IPromise<T> Invoke<T>(Func<T> action) { |
|
113 | 128 | Safe.ArgumentNotNull(action, "action"); |
|
114 | 129 | |
|
115 | 130 | if (m_syncContext == null) |
|
116 | 131 | throw new InvalidOperationException(); |
|
117 | 132 | var p = new Promise<T>(); |
|
118 | 133 | var lop = TraceContext.Instance.CurrentOperation; |
|
119 | 134 | |
|
120 | 135 | m_syncContext.Post(x => { |
|
121 | 136 | TraceContext.Instance.EnterLogicalOperation(lop, false); |
|
122 | 137 | try { |
|
123 | 138 | if (p.CancelOperationIfRequested()) |
|
124 | 139 | return; |
|
125 | 140 | p.Resolve(action()); |
|
126 | 141 | } catch (Exception e) { |
|
127 | 142 | p.Reject(e); |
|
128 | 143 | } finally { |
|
129 | 144 | TraceContext.Instance.Leave(); |
|
130 | 145 | } |
|
131 | 146 | }, null); |
|
132 | 147 | |
|
133 | 148 | return p; |
|
134 | 149 | } |
|
135 | 150 | |
|
136 | 151 | |
|
137 | 152 | /// <summary> |
|
138 | 153 | /// Starts the apartment thread |
|
139 | 154 | /// </summary> |
|
140 | 155 | /// <returns>Promise which will be fullfiled when the syncronization |
|
141 | 156 | /// context will be ready to accept tasks.</returns> |
|
142 | 157 | protected override IPromise OnStart() { |
|
143 | 158 | m_worker.Start(); |
|
144 | 159 | return m_threadStarted; |
|
145 | 160 | } |
|
146 | 161 | |
|
147 | 162 | /// <summary> |
|
148 | 163 | /// Posts quit message to the message loop of the apartment |
|
149 | 164 | /// </summary> |
|
150 | 165 | /// <returns>Promise</returns> |
|
151 | 166 | protected override IPromise OnStop() { |
|
152 | 167 | m_syncContext.Post(x => Application.ExitThread(), null); |
|
153 | 168 | return m_threadTerminated; |
|
154 | 169 | } |
|
155 | 170 | |
|
156 | 171 | void WorkerEntry() { |
|
157 | 172 | m_syncContext = new WindowsFormsSynchronizationContext(); |
|
158 | 173 | SynchronizationContext.SetSynchronizationContext(m_syncContext); |
|
159 | ||
|
174 | m_enterPromise = new SyncContextPromise(m_syncContext); | |
|
160 | 175 | m_threadStarted.Resolve(); |
|
176 | m_enterPromise.Resolve(); | |
|
161 | 177 | |
|
162 | 178 | Application.OleRequired(); |
|
163 | 179 | Application.Run(); |
|
164 | 180 | |
|
165 | 181 | try { |
|
166 | 182 | OnShutdown(); |
|
167 | 183 | m_threadTerminated.Resolve(); |
|
168 | 184 | } catch(Exception err) { |
|
169 | 185 | m_threadTerminated.Reject(err); |
|
170 | 186 | } |
|
171 | 187 | } |
|
172 | 188 | |
|
173 | 189 | /// <summary> |
|
174 | 190 | /// Called from the STA apartment after the message loop is terminated, override this |
|
175 | 191 | /// method to handle apartment cleanup. |
|
176 | 192 | /// </summary> |
|
177 | 193 | protected virtual void OnShutdown() { |
|
178 | 194 | } |
|
179 | 195 | |
|
180 | 196 | protected override void Dispose(bool disposing) { |
|
181 | 197 | if (disposing) { |
|
182 | 198 | if (!m_threadTerminated.IsResolved) |
|
183 | 199 | m_syncContext.Post(x => Application.ExitThread(), null); |
|
184 | 200 | } |
|
185 | 201 | base.Dispose(disposing); |
|
186 | 202 | } |
|
187 | 203 | } |
|
188 | 204 | } |
@@ -1,274 +1,275 | |||
|
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 | <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid> |
|
7 | 7 | <OutputType>Library</OutputType> |
|
8 | 8 | <RootNamespace>Implab</RootNamespace> |
|
9 | 9 | <AssemblyName>Implab</AssemblyName> |
|
10 | 10 | <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|
11 | 11 | <ReleaseVersion>0.2</ReleaseVersion> |
|
12 | 12 | <ProductVersion>8.0.30703</ProductVersion> |
|
13 | 13 | <SchemaVersion>2.0</SchemaVersion> |
|
14 | 14 | </PropertyGroup> |
|
15 | 15 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
16 | 16 | <DebugSymbols>true</DebugSymbols> |
|
17 | 17 | <DebugType>full</DebugType> |
|
18 | 18 | <Optimize>false</Optimize> |
|
19 | 19 | <OutputPath>bin\Debug</OutputPath> |
|
20 | 20 | <DefineConstants>TRACE;DEBUG;</DefineConstants> |
|
21 | 21 | <ErrorReport>prompt</ErrorReport> |
|
22 | 22 | <WarningLevel>4</WarningLevel> |
|
23 | 23 | <ConsolePause>false</ConsolePause> |
|
24 | 24 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
25 | 25 | </PropertyGroup> |
|
26 | 26 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
27 | 27 | <DebugType>full</DebugType> |
|
28 | 28 | <Optimize>true</Optimize> |
|
29 | 29 | <OutputPath>bin\Release</OutputPath> |
|
30 | 30 | <ErrorReport>prompt</ErrorReport> |
|
31 | 31 | <WarningLevel>4</WarningLevel> |
|
32 | 32 | <ConsolePause>false</ConsolePause> |
|
33 | 33 | </PropertyGroup> |
|
34 | 34 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' "> |
|
35 | 35 | <DebugSymbols>true</DebugSymbols> |
|
36 | 36 | <DebugType>full</DebugType> |
|
37 | 37 | <Optimize>false</Optimize> |
|
38 | 38 | <OutputPath>bin\Debug</OutputPath> |
|
39 | 39 | <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants> |
|
40 | 40 | <ErrorReport>prompt</ErrorReport> |
|
41 | 41 | <WarningLevel>4</WarningLevel> |
|
42 | 42 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
43 | 43 | <ConsolePause>false</ConsolePause> |
|
44 | 44 | </PropertyGroup> |
|
45 | 45 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' "> |
|
46 | 46 | <Optimize>true</Optimize> |
|
47 | 47 | <OutputPath>bin\Release</OutputPath> |
|
48 | 48 | <ErrorReport>prompt</ErrorReport> |
|
49 | 49 | <WarningLevel>4</WarningLevel> |
|
50 | 50 | <ConsolePause>false</ConsolePause> |
|
51 | 51 | <DefineConstants>NET_4_5</DefineConstants> |
|
52 | 52 | </PropertyGroup> |
|
53 | 53 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' "> |
|
54 | 54 | <DebugSymbols>true</DebugSymbols> |
|
55 | 55 | <DebugType>full</DebugType> |
|
56 | 56 | <Optimize>false</Optimize> |
|
57 | 57 | <OutputPath>bin\Debug</OutputPath> |
|
58 | 58 | <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants> |
|
59 | 59 | <ErrorReport>prompt</ErrorReport> |
|
60 | 60 | <WarningLevel>4</WarningLevel> |
|
61 | 61 | <RunCodeAnalysis>true</RunCodeAnalysis> |
|
62 | 62 | <ConsolePause>false</ConsolePause> |
|
63 | 63 | </PropertyGroup> |
|
64 | 64 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' "> |
|
65 | 65 | <Optimize>true</Optimize> |
|
66 | 66 | <OutputPath>bin\Release</OutputPath> |
|
67 | 67 | <DefineConstants>NET_4_5;MONO;</DefineConstants> |
|
68 | 68 | <ErrorReport>prompt</ErrorReport> |
|
69 | 69 | <WarningLevel>4</WarningLevel> |
|
70 | 70 | <ConsolePause>false</ConsolePause> |
|
71 | 71 | </PropertyGroup> |
|
72 | 72 | <ItemGroup> |
|
73 | 73 | <Reference Include="System" /> |
|
74 | 74 | <Reference Include="System.Xml" /> |
|
75 | 75 | <Reference Include="mscorlib" /> |
|
76 | 76 | </ItemGroup> |
|
77 | 77 | <ItemGroup> |
|
78 | 78 | <Compile Include="Components\StateChangeEventArgs.cs" /> |
|
79 | 79 | <Compile Include="CustomEqualityComparer.cs" /> |
|
80 | 80 | <Compile Include="Diagnostics\ConsoleTraceListener.cs" /> |
|
81 | 81 | <Compile Include="Diagnostics\LogChannel.cs" /> |
|
82 | 82 | <Compile Include="Diagnostics\LogicalOperation.cs" /> |
|
83 | 83 | <Compile Include="Diagnostics\TextFileListener.cs" /> |
|
84 | 84 | <Compile Include="Diagnostics\TraceLog.cs" /> |
|
85 | 85 | <Compile Include="Diagnostics\TraceEvent.cs" /> |
|
86 | 86 | <Compile Include="Diagnostics\TraceEventType.cs" /> |
|
87 | 87 | <Compile Include="ICancellable.cs" /> |
|
88 | 88 | <Compile Include="IProgressHandler.cs" /> |
|
89 | 89 | <Compile Include="IProgressNotifier.cs" /> |
|
90 | 90 | <Compile Include="IPromiseT.cs" /> |
|
91 | 91 | <Compile Include="IPromise.cs" /> |
|
92 | 92 | <Compile Include="IServiceLocator.cs" /> |
|
93 | 93 | <Compile Include="ITaskController.cs" /> |
|
94 | 94 | <Compile Include="Parallels\DispatchPool.cs" /> |
|
95 | 95 | <Compile Include="Parallels\ArrayTraits.cs" /> |
|
96 | 96 | <Compile Include="Parallels\MTQueue.cs" /> |
|
97 | 97 | <Compile Include="Parallels\WorkerPool.cs" /> |
|
98 | 98 | <Compile Include="ProgressInitEventArgs.cs" /> |
|
99 | 99 | <Compile Include="Properties\AssemblyInfo.cs" /> |
|
100 | 100 | <Compile Include="Parallels\AsyncPool.cs" /> |
|
101 | 101 | <Compile Include="Safe.cs" /> |
|
102 | <Compile Include="SyncContextPromise.cs" /> | |
|
102 | 103 | <Compile Include="ValueEventArgs.cs" /> |
|
103 | 104 | <Compile Include="PromiseExtensions.cs" /> |
|
104 | <Compile Include="SyncContextPromise.cs" /> | |
|
105 | <Compile Include="SyncContextPromiseT.cs" /> | |
|
105 | 106 | <Compile Include="Diagnostics\OperationContext.cs" /> |
|
106 | 107 | <Compile Include="Diagnostics\TraceContext.cs" /> |
|
107 | 108 | <Compile Include="Diagnostics\LogEventArgs.cs" /> |
|
108 | 109 | <Compile Include="Diagnostics\LogEventArgsT.cs" /> |
|
109 | 110 | <Compile Include="Diagnostics\Extensions.cs" /> |
|
110 | 111 | <Compile Include="PromiseEventType.cs" /> |
|
111 | 112 | <Compile Include="Parallels\AsyncQueue.cs" /> |
|
112 | 113 | <Compile Include="PromiseT.cs" /> |
|
113 | 114 | <Compile Include="IDeferred.cs" /> |
|
114 | 115 | <Compile Include="IDeferredT.cs" /> |
|
115 | 116 | <Compile Include="Promise.cs" /> |
|
116 | 117 | <Compile Include="PromiseTransientException.cs" /> |
|
117 | 118 | <Compile Include="Parallels\Signal.cs" /> |
|
118 | 119 | <Compile Include="Parallels\SharedLock.cs" /> |
|
119 | 120 | <Compile Include="Diagnostics\ILogWriter.cs" /> |
|
120 | 121 | <Compile Include="Diagnostics\ListenerBase.cs" /> |
|
121 | 122 | <Compile Include="Parallels\BlockingQueue.cs" /> |
|
122 | 123 | <Compile Include="AbstractEvent.cs" /> |
|
123 | 124 | <Compile Include="AbstractPromise.cs" /> |
|
124 | 125 | <Compile Include="AbstractPromiseT.cs" /> |
|
125 | 126 | <Compile Include="FuncTask.cs" /> |
|
126 | 127 | <Compile Include="FuncTaskBase.cs" /> |
|
127 | 128 | <Compile Include="FuncTaskT.cs" /> |
|
128 | 129 | <Compile Include="ActionChainTaskBase.cs" /> |
|
129 | 130 | <Compile Include="ActionChainTask.cs" /> |
|
130 | 131 | <Compile Include="ActionChainTaskT.cs" /> |
|
131 | 132 | <Compile Include="FuncChainTaskBase.cs" /> |
|
132 | 133 | <Compile Include="FuncChainTask.cs" /> |
|
133 | 134 | <Compile Include="FuncChainTaskT.cs" /> |
|
134 | 135 | <Compile Include="ActionTaskBase.cs" /> |
|
135 | 136 | <Compile Include="ActionTask.cs" /> |
|
136 | 137 | <Compile Include="ActionTaskT.cs" /> |
|
137 | 138 | <Compile Include="ICancellationToken.cs" /> |
|
138 | 139 | <Compile Include="SuccessPromise.cs" /> |
|
139 | 140 | <Compile Include="SuccessPromiseT.cs" /> |
|
140 | 141 | <Compile Include="PromiseAwaiterT.cs" /> |
|
141 | 142 | <Compile Include="PromiseAwaiter.cs" /> |
|
142 | 143 | <Compile Include="Components\ComponentContainer.cs" /> |
|
143 | 144 | <Compile Include="Components\Disposable.cs" /> |
|
144 | 145 | <Compile Include="Components\DisposablePool.cs" /> |
|
145 | 146 | <Compile Include="Components\ObjectPool.cs" /> |
|
146 | 147 | <Compile Include="Components\ServiceLocator.cs" /> |
|
147 | 148 | <Compile Include="Components\IInitializable.cs" /> |
|
148 | 149 | <Compile Include="TaskController.cs" /> |
|
149 | 150 | <Compile Include="Components\App.cs" /> |
|
150 | 151 | <Compile Include="Components\IRunnable.cs" /> |
|
151 | 152 | <Compile Include="Components\ExecutionState.cs" /> |
|
152 | 153 | <Compile Include="Components\RunnableComponent.cs" /> |
|
153 | 154 | <Compile Include="Components\IFactory.cs" /> |
|
154 | 155 | <Compile Include="Automaton\IAlphabet.cs" /> |
|
155 | 156 | <Compile Include="Automaton\ParserException.cs" /> |
|
156 | 157 | <Compile Include="Automaton\IndexedAlphabetBase.cs" /> |
|
157 | 158 | <Compile Include="Automaton\IAlphabetBuilder.cs" /> |
|
158 | 159 | <Compile Include="Automaton\RegularExpressions\AltToken.cs" /> |
|
159 | 160 | <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" /> |
|
160 | 161 | <Compile Include="Automaton\RegularExpressions\CatToken.cs" /> |
|
161 | 162 | <Compile Include="Automaton\RegularExpressions\StarToken.cs" /> |
|
162 | 163 | <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" /> |
|
163 | 164 | <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" /> |
|
164 | 165 | <Compile Include="Automaton\RegularExpressions\Token.cs" /> |
|
165 | 166 | <Compile Include="Automaton\RegularExpressions\IVisitor.cs" /> |
|
166 | 167 | <Compile Include="Automaton\AutomatonTransition.cs" /> |
|
167 | 168 | <Compile Include="Formats\JSON\JSONElementContext.cs" /> |
|
168 | 169 | <Compile Include="Formats\JSON\JSONElementType.cs" /> |
|
169 | 170 | <Compile Include="Formats\JSON\JSONGrammar.cs" /> |
|
170 | 171 | <Compile Include="Formats\JSON\JSONParser.cs" /> |
|
171 | 172 | <Compile Include="Formats\JSON\JSONScanner.cs" /> |
|
172 | 173 | <Compile Include="Formats\JSON\JsonTokenType.cs" /> |
|
173 | 174 | <Compile Include="Formats\JSON\JSONWriter.cs" /> |
|
174 | 175 | <Compile Include="Formats\JSON\JSONXmlReader.cs" /> |
|
175 | 176 | <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" /> |
|
176 | 177 | <Compile Include="Formats\JSON\StringTranslator.cs" /> |
|
177 | 178 | <Compile Include="Automaton\MapAlphabet.cs" /> |
|
178 | 179 | <Compile Include="Formats\CharAlphabet.cs" /> |
|
179 | 180 | <Compile Include="Formats\ByteAlphabet.cs" /> |
|
180 | 181 | <Compile Include="Automaton\IDFATable.cs" /> |
|
181 | 182 | <Compile Include="Automaton\IDFATableBuilder.cs" /> |
|
182 | 183 | <Compile Include="Automaton\DFATable.cs" /> |
|
183 | 184 | <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitor.cs" /> |
|
184 | 185 | <Compile Include="Automaton\RegularExpressions\ITaggedDFABuilder.cs" /> |
|
185 | 186 | <Compile Include="Formats\TextScanner.cs" /> |
|
186 | 187 | <Compile Include="Formats\StringScanner.cs" /> |
|
187 | 188 | <Compile Include="Formats\ReaderScanner.cs" /> |
|
188 | 189 | <Compile Include="Formats\ScannerContext.cs" /> |
|
189 | 190 | <Compile Include="Formats\Grammar.cs" /> |
|
190 | 191 | <Compile Include="Automaton\RegularExpressions\EndTokenT.cs" /> |
|
191 | 192 | <Compile Include="Automaton\RegularExpressions\EndToken.cs" /> |
|
192 | 193 | <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitorT.cs" /> |
|
193 | 194 | <Compile Include="Automaton\AutomatonConst.cs" /> |
|
194 | 195 | <Compile Include="Automaton\RegularExpressions\RegularDFA.cs" /> |
|
195 | 196 | <Compile Include="Components\LazyAndWeak.cs" /> |
|
196 | 197 | <Compile Include="AbstractTask.cs" /> |
|
197 | 198 | <Compile Include="AbstractTaskT.cs" /> |
|
198 | 199 | <Compile Include="FailedPromise.cs" /> |
|
199 | 200 | <Compile Include="FailedPromiseT.cs" /> |
|
200 | 201 | <Compile Include="Components\PollingComponent.cs" /> |
|
201 | 202 | </ItemGroup> |
|
202 | 203 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|
203 | 204 | <ItemGroup /> |
|
204 | 205 | <ProjectExtensions> |
|
205 | 206 | <MonoDevelop> |
|
206 | 207 | <Properties> |
|
207 | 208 | <Policies> |
|
208 | 209 | <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" /> |
|
209 | 210 | <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" /> |
|
210 | 211 | <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" /> |
|
211 | 212 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" /> |
|
212 | 213 | <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" /> |
|
213 | 214 | <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" /> |
|
214 | 215 | <NameConventionPolicy> |
|
215 | 216 | <Rules> |
|
216 | 217 | <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
217 | 218 | <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
218 | 219 | <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
219 | 220 | <RequiredPrefixes> |
|
220 | 221 | <String>I</String> |
|
221 | 222 | </RequiredPrefixes> |
|
222 | 223 | </NamingRule> |
|
223 | 224 | <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
224 | 225 | <RequiredSuffixes> |
|
225 | 226 | <String>Attribute</String> |
|
226 | 227 | </RequiredSuffixes> |
|
227 | 228 | </NamingRule> |
|
228 | 229 | <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
229 | 230 | <RequiredSuffixes> |
|
230 | 231 | <String>EventArgs</String> |
|
231 | 232 | </RequiredSuffixes> |
|
232 | 233 | </NamingRule> |
|
233 | 234 | <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
234 | 235 | <RequiredSuffixes> |
|
235 | 236 | <String>Exception</String> |
|
236 | 237 | </RequiredSuffixes> |
|
237 | 238 | </NamingRule> |
|
238 | 239 | <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
239 | 240 | <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" /> |
|
240 | 241 | <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
241 | 242 | <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" /> |
|
242 | 243 | <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
243 | 244 | <RequiredPrefixes> |
|
244 | 245 | <String>m_</String> |
|
245 | 246 | </RequiredPrefixes> |
|
246 | 247 | </NamingRule> |
|
247 | 248 | <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True"> |
|
248 | 249 | <RequiredPrefixes> |
|
249 | 250 | <String>_</String> |
|
250 | 251 | </RequiredPrefixes> |
|
251 | 252 | </NamingRule> |
|
252 | 253 | <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False"> |
|
253 | 254 | <RequiredPrefixes> |
|
254 | 255 | <String>m_</String> |
|
255 | 256 | </RequiredPrefixes> |
|
256 | 257 | </NamingRule> |
|
257 | 258 | <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
258 | 259 | <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
259 | 260 | <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
260 | 261 | <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
261 | 262 | <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" /> |
|
262 | 263 | <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True"> |
|
263 | 264 | <RequiredPrefixes> |
|
264 | 265 | <String>T</String> |
|
265 | 266 | </RequiredPrefixes> |
|
266 | 267 | </NamingRule> |
|
267 | 268 | </Rules> |
|
268 | 269 | </NameConventionPolicy> |
|
269 | 270 | </Policies> |
|
270 | 271 | </Properties> |
|
271 | 272 | </MonoDevelop> |
|
272 | 273 | </ProjectExtensions> |
|
273 | 274 | <ItemGroup /> |
|
274 | 275 | </Project> No newline at end of file |
@@ -1,18 +1,21 | |||
|
1 |
using System |
|
|
2 | using System; | |
|
3 | ||
|
4 | namespace Implab { | |
|
5 | public class SyncContextPromise<T> : Promise<T> { | |
|
6 | readonly SynchronizationContext m_context; | |
|
7 | ||
|
8 |
|
|
|
9 | Safe.ArgumentNotNull(context, "context"); | |
|
10 | m_context = context; | |
|
11 | } | |
|
12 | ||
|
13 | protected override void SignalHandler(HandlerDescriptor handler, int signal) { | |
|
14 | m_context.Post(x => base.SignalHandler(handler, signal), null); | |
|
15 | } | |
|
16 | } | |
|
17 | } | |
|
18 | ||
|
1 | using System; | |
|
2 | using System.Collections.Generic; | |
|
3 | using System.Linq; | |
|
4 | using System.Text; | |
|
5 | using System.Threading; | |
|
6 | ||
|
7 | namespace Implab { | |
|
8 | public class SyncContextPromise : Promise { | |
|
9 | readonly SynchronizationContext m_context; | |
|
10 | ||
|
11 | public SyncContextPromise(SynchronizationContext context) { | |
|
12 | Safe.ArgumentNotNull(context, "context"); | |
|
13 | ||
|
14 | m_context = context; | |
|
15 | } | |
|
16 | ||
|
17 | protected override void SignalHandler(HandlerDescriptor handler, int signal) { | |
|
18 | m_context.Post(x => base.SignalHandler(handler, signal), null); | |
|
19 | } | |
|
20 | } | |
|
21 | } |
General Comments 3
ok, latest stable version should be in default
You need to be logged in to leave comments.
Login now