2014-04-07 44 views
0

我有一个BackgroundWorker,包括读/写IsolatedStorage。在工作人员运行之前,我从IsolatedStorage中读取数据。我是否必须担心使用互斥锁,还是只有在读取完成后才开始工作?BackgroundWorker在上一行代码之前运行?

//read from IsolatedStorage here 

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

回答

1

有你要考虑几件事情:

  • 如果bgw.RunWorkerAsync();之前,你的代码运行同步,
  • 如果IsolatedStorage操作也被执行为同步,
  • 如果bgw是怎么回事只使用IsolatedStorage的任务/线程/进程(检查所有事件,方法,构造函数... - 也是IsolatedStorageSettings,其他方法例如SaveJpg,
  • 如果你处置你的ISF和所有IsolatedStorageStreams

然后就没有问题,你可以做到没有互斥。但海事组织会更安全/更好地使用一个 - here in the answer你有一个很好的模式。

相关问题