Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2938d16

Browse files
committed
use JoinableTaskContext directly
1 parent0da4d93 commit2938d16

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

‎vsintegration/src/FSharp.LanguageService.Base/DocumentTask.cs‎

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,45 @@ public static void RunSync(Action a)
161161
}
162162
}
163163

164+
/// <summary>
165+
/// Local JoinableTaskContext
166+
/// ensuring non-reentrancy.
167+
/// </summary>
168+
privatestaticJoinableTaskContextjtc=null;
169+
privatestaticJoinableTaskFactoryJTF
170+
{
171+
get
172+
{
173+
if(jtc==null)
174+
{
175+
JoinableTaskContextj=null;
176+
if(VsTaskLibraryHelper.ServiceInstance==null)
177+
{
178+
j=newJoinableTaskContext();
179+
}
180+
else
181+
{
182+
j=ThreadHelper.JoinableTaskContext;
183+
}
184+
Interlocked.CompareExchange(refjtc,j,null);
185+
}
186+
187+
returnjtc.Factory;
188+
}
189+
}
190+
164191
/// <summary>
165192
/// Performs a callback on the UI thread and blocks until it is done, using the VS mechanism for
166193
/// ensuring non-reentrancy.
167194
/// </summary>
168195
[SuppressMessage("Microsoft.Design","CA1031:DoNotCatchGeneralExceptionTypes")]
169196
internalstaticTDoOnUIThread<T>(Func<T>callback)
170197
{
171-
returnThreadHelper.JoinableTaskFactory.Run<T>(asyncdelegate
172-
{
173-
awaitThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
174-
returncallback();
175-
});
198+
returnJTF.JoinableTaskFactory.Run<T>(asyncdelegate
199+
{
200+
awaitJTF.SwitchToMainThreadAsync();
201+
returncallback();
202+
});
176203
}
177204

178205
/// <summary>
@@ -182,11 +209,11 @@ internal static T DoOnUIThread<T>(Func<T> callback)
182209
[SuppressMessage("Microsoft.Design","CA1031:DoNotCatchGeneralExceptionTypes")]
183210
internalstaticvoidDoOnUIThread(Actioncallback)
184211
{
185-
ThreadHelper.JoinableTaskFactory.Run(asyncdelegate
186-
{
187-
awaitThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
188-
callback();
189-
});
212+
returnJTF.Run<T>(asyncdelegate
213+
{
214+
awaitJTF.SwitchToMainThreadAsync();
215+
returncallback();
216+
});
190217
}
191218
}
192219

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp