SendTo menu and single instance program
I'm making a program through which I will be able to send files to an FTP server just by right clicking "SendTo". The problem is that every time I click "SendTo" it opens a new exe file and it works as a separate program. I need to make it somehow to send the file with the already ope开发者_高级运维n program.
Thank you.
Here is an example application with source code: Single Instance Application, Passing Command Line Arguments.
The examples uses .Net Remoting to pass the arguments between instances but you can change it to use WCF, sockets or pipes.
You can achieve a single instance with a Mutex.
Place this in your startup class. E.g. Program.cs
private static Mutex _mutex;
[STAThread]
static void Main (string[] args)
{
// Ensure only one instance runs at a time
_mutex = new Mutex (true, "MyMutexName");
if (!_mutex.WaitOne (0, false))
{
return;
}
}
But check MSDN for details: http://msdn.microsoft.com/en-us/library/ms686927%28VS.85%29.aspx
精彩评论