I want my c# winform application to switch to another running instance if a certain event occurs.
For example if I have a application with just a button and three instances are running at the moment. Now if I
- press the button in first instance, focus to second instance
- press the button in second instance, focus to third instance
- press the button in third instance, focus to first instance
How do i do that?
if you know the handle of the other instances you should just call the Windows API: SetForegroundWindow:
you can use the FindWindow API call to get the handle of the other instances, for example:
you can search for those api calls here in SO for more examples, for example found this one:
How do I focus a foreign window?