private void MainFrm_Load(object sender, EventArgs e) { if (this.onLoadArgs != null) { InitProject(this.onLoadArgs.Project, this.onLoadArgs.ProjectFile); this.onLoadArgs = null; } this.Text = this.projController.GetTitleBarText(); }
private void OnLoadThreadProc(object context) { OnLoadArgs ola = (OnLoadArgs)context; try { ola.output = OnLoadImpl(ola.input); } catch (Exception ex) { ola.exception = ex; } }
protected override Document OnLoad(Stream input) { Document document; // WIC does not support MTA, so we must marshal this stuff to another thread // that is then guaranteed to be STA. switch (Thread.CurrentThread.GetApartmentState()) { case ApartmentState.Unknown: case ApartmentState.MTA: OnLoadArgs ola = new OnLoadArgs(); ola.input = input; ola.output = null; ParameterizedThreadStart pts = new ParameterizedThreadStart(OnLoadThreadProc); Thread staThread = new Thread(pts); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(ola); staThread.Join(); if (ola.exception != null) { throw new ApplicationException("OnLoadImpl() threw an exception", ola.exception); } document = ola.output; break; case ApartmentState.STA: document = OnLoadImpl(input); break; default: throw new InvalidEnumArgumentException(); } return(document); }
protected override Document OnLoad(Stream input) { Document document; // WIC does not support MTA, so we must marshal this stuff to another thread // that is then guaranteed to be STA. switch (Thread.CurrentThread.GetApartmentState()) { case ApartmentState.Unknown: case ApartmentState.MTA: OnLoadArgs ola = new OnLoadArgs(); ola.input = input; ola.output = null; ParameterizedThreadStart pts = new ParameterizedThreadStart(OnLoadThreadProc); Thread staThread = new Thread(pts); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(ola); staThread.Join(); if (ola.exception != null) { throw new ApplicationException("OnLoadImpl() threw an exception", ola.exception); } document = ola.output; break; case ApartmentState.STA: document = OnLoadImpl(input); break; default: throw new InvalidEnumArgumentException(); } return document; }
public MainFrm(OnLoadArgs onLoadArgs) : this() { this.onLoadArgs = onLoadArgs; }