I am writing a C # program that will launch many child processes. After some time, I will need to restore these processes by identifier, and then compare these processes with the set of processes stored in the dictionary that were added to the dictionary when they were created. However, I run into a problem that seems pure ridicule ...
Process notepad = new Process();
notepad.StartInfo.FileName = "notepad";
notepad.Start();
Process n2 = Process.GetProcessById(notepad.Id);
Debug.WriteLine(notepad == n2);
Debug.WriteLine(notepad.Id == n2.Id);
I used the .NET Reflector to find out that GetProcessById returns a "new process (...)", but it looks like it should just find a link to an already running process and return it instead.
You can assume that the first Debug statement is essentially a call of type
Data MyCustomDataType = myDictionary [notepad];
, , KeyNotFoundException, , , . , IComparer , , , , . , , , , IComparer Process.ID InvalidOperationException!!! , .
, :