Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WCF Host - subscribe / publish pattern. It is hosted in a Windows Service that gets updates from a client service (not wcf client).
When those updates I arrive - I am pushing those out to a Winform GUI - fire and forget. Since I may have a little or a lot of data from Multiple events, I would like to free the main thread by threading out the publishing.
How can I add a thread to publish the service with out crashing the WCF Host.
My test case code is below.
I have tried this: [But I tend to get InvalidOperation error because
UpdateProductoperation.OperationCompleted
.
Any help is greatly appreciated. Thank you.
C#
void StartUpdateTest()
{
UpdateProductoperation = AsyncOperationManager.CreateOperation(null);

UpdateProductThread = new Thread(new ThreadStart(UpdateProductTestData));

UpdateProductThread.Start();
}

public static void UpdateProductTestData()
		{

UpdateProductoperation.Post(new SendOrPostCallback(delegate(object state)
			    {
			     Random rdm = new Random();
			     int a = rdm.Next(1,20);
			     List<PRODUCT> productList = new List<PRODUCT>();
			                                               	
for (int i = 0; i < a; i++)
{
productList.Add(CreateProductTestData("20251" + a.ToString(), i));
}
        WCFServer.PublishProductChanged(productList);
// thinking to try this here.	UpdateProductoperation.OperationCompleted();
	 }), null); // end of delegate here.

// tried:	UpdateProductoperation.OperationCompleted();
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900