Bidou Bidou - 1 year ago 127
C# Question

Process.Start is very slow

I'm currently using this method and it works perfectly:

public static void CreateEmailInDefaultMailEditor(string to, string subject, string body)

I then tried it on another computer and its also working there but it's VERY slow (more that one minute to open my mail editor!).

I debugged the
(in System.dll) method and found out that the problem was at the end the
method that runs very slowly.

I also noticed that specifying the name of the program that should open to send the email

public static void CreateEmailInOutlook(string to, string subject, string body)
Process.Start("outlook.exe", $"mailto:{to}?subject={subject}&body={body}");

solves the problem but that does not explain why it's working correctly on a computer and not on the other and it doesn't do the same thing: not specifing the program automatically opens the default one.

So the question is quite simple: Why this behavior and how to workaround it?

Answer Source

Thank you for the answers & comments.

Here a small update to the question and probably the solution (I'm still not completely sure what the problem was): I could reproduce the problem to every computers of my department I tested (and not just two as mentioned in my question). After a few days, I noticed that everything was working again. I didn't change the code of my program nor did I deactivate the anti-virus.

What I didn't mentioned in my question (I thought it was not important), is that all computers were new. And I think it could be the problem: Windows has an Index Service, and I can imagine that at the beginning, it could take some days until the whole computer has been scanned. Searching for the default mail manager can in this case take long time, but as soon as the Indexing Service has done his job, searching for the default mail manager is fast again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download