|
I am trying to open a new window once a workflow is completed. I am using the following code:
public void InizializeFlickrPhotosGetSizesWorkflow(string photoId, string title, ImageSource image, string description, string tags) { parameters = new Dictionary<string, object>(); parameters.Add("PhotoId", photoId); try { if ((this.workflowRuntime = new WorkflowRuntime()) == null) { throw new System.Exception("There was a problem creating the workflow runtime.\nThe Application will now exit."); } else { // Add the External Data Exchange Service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); // Add dataService to the workflow runtime this.workflowRuntime.AddService(dataService); //Add GetLiveSearchKey to the dataService dataService.AddService(new FlickrAPI.FlickrKeys()); } } catch (System.Exception ex) { System.Windows.MessageBox.Show(ex.Message.ToString()); } this.instance = workflowRuntime.CreateWorkflow(typeof(FlickrActivityLibrary.FlickrPhotosGetSizes), parameters); this.workflowRuntime.WorkflowCompleted += delegate(object s, WorkflowCompletedEventArgs ex) { Thread newWindowThread = new Thread(delegate() { previewPhotoWindow=new PhotoView(int.Parse((ex.OutputParameters["LargeHeight"] as String)), int.Parse((ex.OutputParameters["LargeWidth"] as String)), title, image, description, tags); previewPhotoWindow.Show(); } ); newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.Start(); parameters.Clear(); waitHandle.Set(); };
workflowRuntime.WorkflowTerminated += delegate(object s, WorkflowTerminatedEventArgs ex) { System.Windows.MessageBox.Show("WorkflowTerminated"); Console.WriteLine(ex.Exception.Message); parameters.Clear(); waitHandle.Set(); }; }
Once the new window should be shown (the line in bold), I get the following error:
LoaderLock was detected Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
Any ideas why I get this error message? Any help is welcome...
|