jimmygyuma

I've written a program to write web pages for me. They're all similar, I just fill in the blanks. I have a button to open the file in Firefox to make sure it looks okay and that works the way I want; it doesn't start a new instance of FF, the currently running instance just creates a new tab.

Sometimes I have to edit the file or make additions that my program doesn't handle, so I have a button to open the file in jEdit, but that one doesn't work the way I want it to. Instead of opening the file in the running application, it creates a new instance of the application. This is really bizarre because both instances of jEdit have all the same files open, including the new one.

My question is, how do I get the file to open in the currently running instance I'm using:

Process.Start(jEditPath, filePath); and Process.Start(firefoxPath, filePath);. jEdit is a .jar program if that makes any difference.

Thanks,

Jim



Re: Visual C# Express Edition System.Diagnostics.Process.Start question

rauhanlinnake

As the name states, Process.Start begins a new process. In the case of firefox, the browser itself is handling the situation so, that only one process instance of firefox.exe is created. The jEdit is designed so, that is allow multiple processes to be created. It makes sense - if one instance crashes, other files you are editing does not close. Firefox mainstains only one instance, since it consumes much more memory than a text editor.




Re: Visual C# Express Edition System.Diagnostics.Process.Start question

jimmygyuma

Well, I'm not wedded to Start, is there a way to do it so that it doesn't open a new instance of jEdit, but opens it in the currently running instance




Re: Visual C# Express Edition System.Diagnostics.Process.Start question

Ji Cheng Wang - MSFT

Hi jimmy,

Just as rauhanlinnake said, if you use Process.Start to open the file in jEdit through FF, it will begin a new process. Based on my understanding to your questions, I think you can try to place the jEdit component in another web page, then place a LinkButton in a web page and call the JEdit web page to open the file in jEdit in current running FF instance through the PostBackUrl property of the LinkButton. Try to set Target= "_blank" and check if this works for you.

If you get any issues when trying my suggestions, please post back to me. Thanks.

Regards,






Re: Visual C# Express Edition System.Diagnostics.Process.Start question

jimmygyuma

You misunderstand: jEdit is a stand alone editing program that I use to edit my web pages, it has nothing to do with Firefox. I use FF to check if the web pages I'm producing look okay and the links all work, and jEdit if they need more work, i.e., editing. The pages I'm producing are pages of an old logbook, which mostly all follow one of two patterns, which I wrote my program to handle. But sometimes the Captain adds something extra or does something a little differently and I use jEdit to make the changes to the page my program produces.

jEdit is also designed to have only one instance running; if it's running and you double click its icon on the desktop, the already running instance pops up not a new one, same if you right click a file and choose Open with jEdit. As I said, tho my program starts a new instance, both instances have all the same files open including the new one that I wanted to open. Then I have to close one instance, because it doesn't work well with two running.

There is a way to check if there is already an instance running, but I haven't figured out how to tell that instance, 'Here, open this file!'

Thanks,
Jimmy




Re: Visual C# Express Edition System.Diagnostics.Process.Start question

Ji Cheng Wang - MSFT

Hi Jimmy,

Thanks for your quick reply.

If you would like to check if there is already an instance running, you can try to check out the following sample codes for reference:

Code Block

public bool IsAlreadyRunning()
{
string pName = Process.GetCurrentProcess().ProcessName;
Process[] processes = Process.GetProcessesByName(pName);
return (processes.Length > 1);
}

Besides, you can try to check out this FAQ article for reference:

http://www.yoda.arachsys.com/csharp/faq/#one.application.instance

Hope this helps,

Regards,

This response contains links reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.
Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.