本文整理汇总了C#中System.ComponentModel.BackgroundWorker.RunBackground方法的典型用法代码示例。如果您正苦于以下问题:C# BackgroundWorker.RunBackground方法的具体用法?C# BackgroundWorker.RunBackground怎么用?C# BackgroundWorker.RunBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.BackgroundWorker
的用法示例。
在下文中一共展示了BackgroundWorker.RunBackground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MinimizeToFile
public void MinimizeToFile(string targetFile)
{
var targetSkydFile = ChromatogramCache.FinalPathForName(targetFile, null);
using (var skydSaver = new FileSaver(targetSkydFile))
using (var scansSaver = new FileSaver(targetSkydFile + ChromatogramCache.SCANS_EXT, true))
using (var peaksSaver = new FileSaver(targetSkydFile + ChromatogramCache.PEAKS_EXT, true))
using (var scoreSaver = new FileSaver(targetSkydFile + ChromatogramCache.SCORES_EXT, true))
{
skydSaver.Stream = File.OpenWrite(skydSaver.SafeName);
using (var longWaitDlg = new LongWaitDlg(DocumentUIContainer))
{
longWaitDlg.PerformWork(this, 1000,
longWaitBroker =>
{
longWaitBroker.Message = Resources.MinimizeResultsDlg_MinimizeToFile_Saving_new_cache_file;
try
{
using (var backgroundWorker =
new BackgroundWorker(this, longWaitBroker))
{
backgroundWorker.RunBackground(skydSaver.Stream,
scansSaver.FileStream, peaksSaver.FileStream, scoreSaver.FileStream);
}
}
catch (ObjectDisposedException)
{
if (!longWaitBroker.IsCanceled)
{
throw;
}
}
});
if (longWaitDlg.IsCanceled)
{
return;
}
}
var skylineWindow = (SkylineWindow) DocumentUIContainer;
if (!skylineWindow.SaveDocument(targetFile, false))
{
return;
}
try
{
var measuredResults = DocumentUIContainer.Document.Settings.MeasuredResults.CommitCacheFile(skydSaver);
SrmDocument docOrig, docNew;
do
{
docOrig = DocumentUIContainer.Document;
docNew = docOrig.ChangeMeasuredResults(measuredResults);
} while (!DocumentUIContainer.SetDocument(docNew, docOrig));
}
catch (Exception x)
{
var message = TextUtil.LineSeparate(
string.Format(Resources.MinimizeResultsDlg_MinimizeToFile_An_unexpected_error_occurred_while_saving_the_data_cache_file__0__,
targetFile),
x.Message);
MessageDlg.ShowWithException(this, message, x);
return;
}
skylineWindow.InvalidateChromatogramGraphs();
}
DialogResult = DialogResult.OK;
}