public void ScanFile(IWin32Window ParentForm, string FileName)
{
lock (this.FSD) {
if (FileName != null && File.Exists(FileName)) {
this.FSD = new FileScanDialog();
var T = new Thread(() => {
try {
Application.DoEvents();
while (!this.FSD.Visible) {
Thread.Sleep(0);
Application.DoEvents();
}
this.FSD.Invoke(new AnonymousMethod(() => this.FSD.ResetProgress()));
this.FileContents = FileType.LoadAll(FileName, (msg, pct) => this.FSD.Invoke(new AnonymousMethod(() => this.FSD.SetProgress(msg, pct))));
this.FSD.Invoke(new AnonymousMethod(() => this.FSD.Finish()));
} catch {
this.FileContents = null;
}
});
T.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
T.Start();
if (this.FSD.ShowDialog(ParentForm) == DialogResult.Abort) {
this.FSD.Finish();
this.FileContents = null;
}
if (T.IsAlive)
T.Abort();
this.FSD.Dispose();
this.FSD = null;
}
}
}