Setting user environment variables is very slow
According to Environment class sources (can be found here, line 864), after setting user/machine scope environment variable, it calls native SendMessageTimeout function to notify any process about changes in environment. Here is excerpt:
IntPtr r = Win32Native.SendMessageTimeout(
new IntPtr(Win32Native.HWND_BROADCAST),
Win32Native.WM_SETTINGCHANGE,
IntPtr.Zero,
"Environment",
0,
1000,
IntPtr.Zero);
So 1000 milliseconds (1 second) timeout is given to any recipient to process the message. E.g. if 5 of them fail to process it, you could have up to 5 seconds delay. More about SendMessageTimeout can be found in MSDN.
Hope that helps.