philorube
philorube

Reputation: 155

BackgroundWorker run before previous line of code?

I have a BackgroundWorker that includes read/writes to IsolatedStorage. Right before the worker is run, I read from IsolatedStorage. Do I have to worry about using a Mutex, or will the worker only start once the read is completed?

//read from IsolatedStorage here

bgw.RunWorkerAsync();  //includes read/writes to IsolatedStorage

Upvotes: 0

Views: 75

Answers (1)

Romasz
Romasz

Reputation: 29792

There are few things you have to consider:

  • if your code before bgw.RunWorkerAsync(); is run synchronous,
  • if IsolatedStorage operations are performed also as synchronous,
  • if bgw is going to be only Task/Thread/Proccess using IsolatedStorage (check all events, methods, constructors... - also IsolatedStorageSettings, other methods eg. SaveJpg,
  • if you Disposed your ISF and all IsolatedStorageStreams

then there will be no problem and you can do it without Mutex. But IMO it will be much safer/better to use one - here in the answer you have a good pattern.

Upvotes: 1

Related Questions