void Operation(object data) { #if USEAFFINITY // The "extension" method SetThreadProcessorAffinity was missing the "this" notation, // so it's not really an extension hence this style of call. RuntimeExtensions.SetThreadProcessorAffinity(Thread.CurrentThread, 4); #endif try { var workload = data as WorkLoad; XDocument document; using (var stream = new MemoryStream(workload.data)) { document = XDocument.Load(stream); } var body = document.Root.Element("{http://www.w3.org/2006/10/ttaf1}body"); if (body != null && body.HasElements == false) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => OperationSucceeded(null)); } else { var parser = new TimedTextMarkerParser(); var markers = parser.ParseMarkerCollection(document, workload.timeOffset, workload.endTime); System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => OperationSucceeded(markers)); } } catch (Exception ex) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => OperationFailed(ex)); } }
void ParseMarkers(object data) { #if USEAFFINITY // The "extension" method SetThreadProcessorAffinity was missing the "this" notation, // so it's not really an extension hence this style of call. RuntimeExtensions.SetThreadProcessorAffinity(Thread.CurrentThread, 4); #endif try { string result = data as string; XDocument markerXml = XDocument.Parse(result); IEnumerable <MediaMarker> markers = _markerParser.ParseMarkerCollection(markerXml, TimeSpan.Zero, TimeSpan.MaxValue) .Cast <MediaMarker>() .ToList(); System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => ParseSucceeded(markers)); } catch (Exception ex) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => LogParseError(ex)); } }