I have it set so if you open a file, it launches my application and adds it to the start-up arguments. But how can I make it so if I double click on a file it loads it in the application that's already running? Rather than loading each file into it's own instance of the application.
- stackoverflow.com/questions/19147/… elegantcode.com/2011/03/02/… hanselman.com/blog/… blogs.microsoft.co.il/blogs/maxim/archive/2010/02/13/… The above links describe how you can build single instance applicationEhsan Aleem Avee– Ehsan Aleem Avee2012-10-09 05:22:55 +00:00Commented Oct 9, 2012 at 5:22
- My application was WPF (I should of mentioned that, sorry everyone else), so the second solution worked perfectly! Thank you very much.Alexander Forbes-Reed– Alexander Forbes-Reed2012-10-09 06:15:44 +00:00Commented Oct 9, 2012 at 6:15
Add a comment |
3 Answers
Mutex is want you need to have a single instance of the application.
bool createdNew = true; using (Mutex mutex = new Mutex(true, "MyApplicationName", out createdNew)) { if (createdNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } } You can refer this LINK for detailed information.
Comments
use mdiParent and child forms in C# I think it's great feature of vs C#
for more inforamtion: http://msdn.microsoft.com/en-us/library/d4dabts7%28v=vs.80%29.aspx
Comments
You need to make your application single-Instance, see this article: