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.
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);
}), null);
}