Pump Messages During Long Operations + C#
- by Newbie
Hi I have a web service that is doing huge computation and is taking more than a minute.
I have generated the proxy file of the web service and then from my client end I am using the dll(of course I generated the proxy dll).
My client side code is
TimeSeries3D t = new TimeSeries3D();
int portfolioId = 4387919;
string[] str = new string[2];
str[0] = "MKT_CAP";
DateRange dr = new DateRange();
dr.mStartDate = DateTime.Today;
dr.mEndDate = DateTime.Today;
Service1 sc = new Service1();
t = sc.GetAttributesForPortfolio(portfolioId, true, str, dr);
But since it is taking to much time for the server to compute, after 1 minute I am receiving an error message
The CLR has been unable to transition from COM context 0x33caf30 to COM context 0x33cb0a0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Kindly guide me what to do?
Thanks