// This function is registered with the acquisitor to handle // scan finished events. // Note well that this will be called on the acquisitor thread (meaning // no direct GUI manipulation in this function). private void ScanFinishedHandler(object sender, EventArgs e) { lock (this) { // update the datastore dataStore.UpdateTotal(); // save the acquisitior settings in the scan WriteScanSettings(DataStore.CurrentScan); // serialize the last scan string tempPath = Environment.GetEnvironmentVariable("TEMP") + "\\ScanMasterTemp"; if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } serializer.SerializeScanAsBinary(tempPath + "\\scan_" + dataStore.NumberOfScans.ToString(), dataStore.CurrentScan); dataStore.ClearCurrentScan(); // tell the viewers that the scan is finished viewerManager.ScanFinished(); // hint to the GC that now might be a good time GC.Collect(); } }