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

Commiteb8d0cf

Browse files
authored
Fix threading for register for idle time (dotnet#2073)
* Make ProjectSystem.RegisterForIdleTime threadsafe* Better --- simpler fix
1 parent5412d30 commiteb8d0cf

File tree

1 file changed

+26
-19
lines changed
  • vsintegration/src/FSharp.ProjectSystem.FSharp

1 file changed

+26
-19
lines changed

‎vsintegration/src/FSharp.ProjectSystem.FSharp/Project.fs‎

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,23 +190,29 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
190190
// FSI-LINKAGE-POINT: unsited init
191191
do Microsoft.VisualStudio.FSharp.Interactive.Hooks.fsiConsoleWindowPackageCtorUnsited(this:> Package)
192192

193-
let mutablemgr:IOleComponentManager=null
193+
// Get the ComponentManager one time at the start
194+
letmgr:IOleComponentManager= this.GetService(typeof<SOleComponentManager>):?> IOleComponentManager
195+
194196
let mutablecomponentID=0u
195197

196-
letlocker= obj()
198+
letthisLock= obj()
197199

198200
memberthis.RegisterForIdleTime()=
199-
mgr<- this.GetService(typeof<SOleComponentManager>):?> IOleComponentManager
200-
if componentID=0u&&not(isNull mgr)then
201-
letcrinfo= Array.zeroCreate<OLECRINFO>(1)
202-
let mutablecrinfo0= crinfo.[0]
203-
crinfo0.cbSize<- Marshal.SizeOf(typeof<OLECRINFO>)|> uint32
204-
crinfo0.grfcrf<- uint32(_OLECRF.olecrfNeedIdleTime|||_OLECRF.olecrfNeedPeriodicIdleTime)
205-
crinfo0.grfcadvf<- uint32(_OLECADVF.olecadvfModal|||_OLECADVF.olecadvfRedrawOff|||_OLECADVF.olecadvfWarningsOff)
206-
crinfo0.uIdleTimeInterval<-1000u
207-
crinfo.[0]<- crinfo0
208-
mgr.FRegisterComponent(this, crinfo,&componentID)|> ignore
209-
201+
202+
ifnot(isNull mgr)&& componentID=0uthen
203+
lock(thisLock)(fun _->
204+
if componentID=0uthen
205+
letcrinfo= Array.zeroCreate<OLECRINFO>(1)
206+
let mutablecrinfo0= crinfo.[0]
207+
crinfo0.cbSize<- Marshal.SizeOf(typeof<OLECRINFO>)|> uint32
208+
crinfo0.grfcrf<- uint32(_OLECRF.olecrfNeedIdleTime|||_OLECRF.olecrfNeedPeriodicIdleTime)
209+
crinfo0.grfcadvf<- uint32(_OLECADVF.olecadvfModal|||_OLECADVF.olecadvfRedrawOff|||_OLECADVF.olecadvfWarningsOff)
210+
crinfo0.uIdleTimeInterval<-1000u
211+
crinfo.[0]<- crinfo0
212+
213+
mgr.FRegisterComponent(this, crinfo,&componentID)|> ignore
214+
)
215+
210216
/// This method loads a localized string based on the specified resource.
211217
212218
/// <param name="resourceName">Resource to load</param>
@@ -358,11 +364,12 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
358364
VSConstants.S_OK
359365

360366
overridethis.Dispose(disposing)=
361-
try
362-
lock(locker)(fun _->
363-
if componentID<>0u&&not(isNull mgr)then
364-
mgr.FRevokeComponent(componentID)|> ignore
365-
componentID<-0u)
367+
try
368+
ifnot(isNull mgr)&& componentID<>0uthen
369+
lock(thisLock)(fun _->
370+
if componentID<>0uthen
371+
mgr.FRevokeComponent(componentID)|> ignore
372+
componentID<-0u)
366373
finally
367374
base.Dispose(disposing)
368375

@@ -379,7 +386,7 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
379386
overridethis.FDoIdle(grfidlef:uint32)=
380387
// see e.g "C:\Program Files\Microsoft Visual Studio 2008 SDK\VisualStudioIntegration\Common\IDL\olecm.idl" for details
381388
//Trace.Print("CurrentDirectoryDebug", (fun () -> sprintf "curdir='%s'\n" (System.IO.Directory.GetCurrentDirectory()))) // can be useful for watching how GetCurrentDirectory changes
382-
letperiodic=(grfidlef&&&(uint32_OLEIDLEF.oleidlefPeriodic))<>0u
389+
letperiodic=(grfidlef&&&(uint32_OLEIDLEF.oleidlefPeriodic))<>0u
383390
if periodic&&not(isNull mgr)&& mgr.FContinueIdle()<>0then
384391
TaskReporterIdleRegistration.DoIdle(mgr)
385392
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp