I am running a windows form base application, I am using background worker class for httpwebrequest. And using a webbrowser control, both are saving data to an excel sheet. It was working fine or maybe it was luck , now I see sometime the code gets stuck on the insert statement, it just goes in the
myCommand.ExecuteScalar();
does not come out .And after some time i see this:
The CLR has been unable to transition from COM context 0x7833a8 to COM context 0x7838b0 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.
The query where it gets stuck is:
try
{
myCommand.CommandText = "Insert into [outputsheet$] (website,[facebook page],DealTitle,Dealtime,Dealprice,Dealvalue,Dealdiscount,Dealsaving,Linktitle,address,Category,[Type of Deal]) Values('" +
webaddress.Replace("'", "''") + "','" + facbookaddress.Replace("'", "''") + "','" + title.Replace("'", "''") + "','" + dealtime.Replace("'", "''") + "','" +
amount.Replace("'", "''") + "','" + value.Replace("'", "''") + "','" + discount.Replace("'", "''") + "','" + saving.Replace("'", "''") + "','" +
titleweb.Replace("'", "''") + "','" + address.Replace("'", "''") + "','" + categoryName.Replace("'", "''") + "','Now Deals')";
myCommand.ExecuteScalar();
}
catch (Exception exp)
{
}
Kindly help, is there anything i need to do .How to avoid it. Thank you