I have a program made using WinForms in C# that is using API provided by another developer and it has to be run in the main thread (because it is using WM_Messages, but there might be other reasons as well) - so I can't use BackgroundWorker. My program runs for at least 15 minutes with that API. So when I run it and click on the form, it will freeze and crash, because it is not responding. What can I do to make the form responsive and not trigger the Windows alert "The application is not responding" while it is using that API?
Here is the code that I am running in a loop for all fileNames from given folder:
fApi.ApiSetDates(DateTime.MinValue, DateTime.MinValue, invoiceIssueDate.Year, invoiceIssueDate.Month);
try
{
if (fApi.ImportFakturFromXML(fileName) != 0)
{
throw new Exception(fApi.GetLastError());
}
File.Delete(fileName);
}
catch (Exception x)
{
MessageBox.Show(x.ToString());
}