I have a class that controls the process. When calling Stop()or Dispose()in this class, it will first send a TCP command to the process to ask it to close itself, and then look back after 1 second, if it is not closed, call CloseMainWindow(), then wait another second, if it is still running, call Kill().
Now I have List<>this class for managing a bunch of processes. When I would like to remove them from the list, I would manually call Dispose(), then Remove(). I want to make sure that I call Dispose()before losing the only link. Since the call Dispose()will take at least 2 seconds to return, it will take some time if I say that 5 items will be deleted.
So, I intended to have another function called SafeDispose()that returns Invoke() Dispose(). Now remove them from the list and call SafeDispose()instead Dispose()will be immediately, while the classes themselves will be utilized slowly.
Is it advisable to do this?
source
share