private void TestClient()
		{
			SynchronizationContext context = SynchronizationContext.Current;

			//Have to test client on another thread, otherwise there is a deadlock b/c the service is hosted on the main thread.
			ThreadPool.QueueUserWorkItem(delegate
											{
												try
												{
													using (ViewerAutomationServiceClient client = new ViewerAutomationServiceClient())
													{
														client.GetViewers(new GetViewersRequest());
													}

													context.Post(delegate
																	{
																		base.Context.DesktopWindow.ShowMessageBox("Success!", MessageBoxActions.Ok);
																	}, null);
												}
												catch (Exception e)
												{
													context.Post(delegate
													{
														base.Context.DesktopWindow.ShowMessageBox(e.Message, MessageBoxActions.Ok);
													}, null);

												}
											});

		}
예제 #2
0
        private void TestClient()
        {
            SynchronizationContext context = SynchronizationContext.Current;

            //Have to test client on another thread, otherwise there is a deadlock b/c the service is hosted on the main thread.
            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    using (ViewerAutomationServiceClient client = new ViewerAutomationServiceClient())
                    {
                        client.GetViewers(new GetViewersRequest());
                    }

                    context.Post(delegate
                    {
                        base.Context.DesktopWindow.ShowMessageBox("Success!", MessageBoxActions.Ok);
                    }, null);
                }
                catch (Exception e)
                {
                    context.Post(delegate
                    {
                        base.Context.DesktopWindow.ShowMessageBox(e.Message, MessageBoxActions.Ok);
                    }, null);
                }
            });
        }
 public GetViewersResult GetViewers(GetViewersRequest request)
 {
     // Done for reasons of speed, as well as the fact that a call to the service from the same thread
     // that the service is hosted on (the main UI thread) will cause a deadlock.
     if (SynchronizationContext.Current == ViewerAutomationServiceHostTool.HostSynchronizationContext)
     {
         return new ViewerAutomation().GetViewers(request);
     }
     else
     {
         using (ViewerAutomationServiceClient client = new ViewerAutomationServiceClient())
         {
             return client.GetViewers(request);
         }
     }
 }
예제 #4
0
 public GetViewersResult GetViewers(GetViewersRequest request)
 {
     // Done for reasons of speed, as well as the fact that a call to the service from the same thread
     // that the service is hosted on (the main UI thread) will cause a deadlock.
     if (SynchronizationContext.Current == ViewerAutomationServiceHostTool.HostSynchronizationContext)
     {
         return(new ViewerAutomation().GetViewers(request));
     }
     else
     {
         using (ViewerAutomationServiceClient client = new ViewerAutomationServiceClient())
         {
             return(client.GetViewers(request));
         }
     }
 }