5

I have developed a toolbar for Internet Explorer in C# to send and receive URLs from an external application. It ran great in IE6, but I wanted to take advantage of tabbed browsing in the new version (IE7), but I've run into a snag there. It seems in IE7, each tab counts a separate instance, and therefore a separate instance of my toolbar.

For the life of me, I can't find a way to have a single instance appear across every tab in a single IE window. All I can figure to do is register as a com object to the ROT and have each instance communicate and mirror all the others, but that seems needlessly complex. Has anyone found a workaround for this?

directedition
  • 11,145
  • 18
  • 58
  • 79
  • This will be more difficult in IE 8 because each tab may be running in different processes. – Michael Jun 11 '09 at 19:34
  • Indeed, it's about 100x easier in Firefox. I'm surprised a snag like this exists. I was hoping for MS to provide a better API for tabbed browsing, but it just seems to be non-existent. – directedition Jun 11 '09 at 19:37
  • 1
    Separate instances are used to prevent one browser window from crashing the entire browser. Chrome does the same thing. Whether this is a good thing is debatable. – Robert Harvey Jun 12 '09 at 02:52
  • Do you need to have each tab active at the same time? If not, maybe you could try isolating the URL traffic to one tab at a time and let the external application sync the data. – negEntropy Nov 19 '12 at 19:33
  • Possible duplicate of [How to force C# .net app to run only one instance in Windows?](https://stackoverflow.com/questions/184084/how-to-force-c-sharp-net-app-to-run-only-one-instance-in-windows) –  Apr 16 '18 at 04:04

2 Answers2

1

Because you haven't said much about what your toolbar is doing, I'm going to assume that when you have multiple tabs open it's eating some resources... memory, networking, connections on the remote source, etc.

Rather than making sure only one instance is running, my suggestion is to keep track of which tab is active by listening to the WindowStateChanged event, then you could do a variety of things:

  • Shut down your communications while it's inactive.
  • Notify the remote source that the tab isn't active.
  • Simply not show notifications in inactive tabs.
  • Stop any threads you have running in the toolbar.
  • Etc.
Ben Lesh
  • 107,825
  • 47
  • 247
  • 232
0

Seems to me like you want a mutex, to allow only one instance of the application, or perhaps - one instance of an application feeding all instances of your toolbar.

You could check out msdn for gotchas on synchronization.

Robert Harvey is correct and this has become the standard, but getting IE urls from multiple instances appears rather painless.

Community
  • 1
  • 1
J.Wells
  • 1,749
  • 12
  • 13