开发者

Command line arguments and single instance WPF application

开发者 https://www.devze.com 2022-12-18 18:20 出处:网络
the WPF app I have has been redesigned to use tabs and be single instance. The new requirement is now that when launched with command line options and an instance of the app is already running - the a

the WPF app I have has been redesigned to use tabs and be single instance. The new requirement is now that when launched with command line options and an instance of the app is already running - the already running instance should open a new tab and do some work based on the cmdline options.

the single instance is no prob - but how to pass the cmd line args from the just started instance the the already running?

thanks f开发者_如何学运维or any hints!


Take a look at WindowsFormsApplicationBase, it has all the support for that scenario built-in.

Unfortunately it is meant for WinForms, but a quick spin through Reflector should get you all the code you need for a WPF version.


I would approach this with either a sockets solution or just have the new instance write the command line args to a file which is checked and then flushed by the existing instance.


This is mine (no VB, no WinForms, pure): http://blogs.microsoft.co.il/blogs/maxim/archive/2010/02/13/single-instance-application-manager.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消