Here is my code:
ThreadStart threadStart = controller.OpenFile; Thread thread = new Thread(threadStart); thread.Start();
In the OpenFile function, my code looks like:
System.Console.Error.WriteLine('Launching');
The code in OpenFile doesn’t get executed for 30 seconds exactly. It starts immediately on my machine, but in our production environment it takes 30 seconds before that print statement will execute.
Is there a setting or something that might be doing this? Where would I start looking?
As others pointed out – first try to produce a test program which demonstrates the behavior.
If you can’t, try to troubleshoot by: 1. Call the method directly, not in thread, and see how it behaves. 2. Comment out the rest of the code besides the System.Error.WriteLine line
If you still see the the delay in (1), but not in (2), then try to attach to AppDomain.AssemblyLoad Event. I have seen this happen when in the called method there is a call to a web service (it generates a serialization assembly on the fly, so it takes time), or if there is a first reference to external assembly, and it takes time to find and load it. It’s very rare, but I had to deal with this, so it’s worth trying.