private void DownloadData() { panopticonState = Stage2UI.PanopticonState.DOWNLOADING; panopticonPercentage = 0; UpdatePanopticonState(); UpdatePanopticonPercentage(); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler((s, e) => { videoFile = proxy.GetVideoFilename(); panopticonFile = proxy.GetPanopticonFilename(); panopticonInfo = proxy.GetPanopticonInfo(); presses = proxy.GetPresses(); length = proxy.GetStudyLength(); toDownload = proxy.GetVideoSize() + proxy.GetPanopticonSize(); downloaded = 0; Thread t1 = new Thread(() => { if (!File.Exists(videoFile)) { Stream videoStream = fileProxy.DownloadVideo(); DownloadFile(videoStream, videoFile); } }); Thread t2 = new Thread(() => { if (!File.Exists(panopticonFile)) { Stream panopticonStream = fileProxy.DownloadPanopticonVideo(); DownloadFile(panopticonStream, panopticonFile); } }); t1.Start(); t2.Start(); t1.Join(); t2.Join(); panopticonState = Stage2UI.PanopticonState.READY; UpdatePanopticonState(); }); worker.RunWorkerAsync(); }
private void panopticonCLI_Completed(object sender, PanopticonCLI.CompletedEventArgs e) { if (e.Error == null) { IsComplete = true; Info = new PanopticonInfo(panopticonCLI.GridHorizontal, panopticonCLI.GridVertical, panopticonCLI.PanelWidth, panopticonCLI.PanelHeight, panopticonCLI.OutputWidth, panopticonCLI.OutputHeight, panopticonCLI.OutputDuration); Timer t = new Timer(0.25); t.Elapsed += new ElapsedEventHandler(t_Elapsed); t.Start(); } else if(ProcessingFailed != null) { ProcessingFailed(this, e.Error); } }