Now for the funny Part: imagine you have a ClickOnce-Application and you want to use the SingleInstance-Property (provided by VB.NET).
First you have to extend the WindowsFormsApplicationBase from VB and create your own. In this ApplicationBase you can now handle the StartupEvents and handle the SingleInstance.
private class App : WindowsFormsApplicationBase { #region Delegates public delegate void ProcessParametersDelegate(object sender, string[] args); #endregion public bool IsSingle { set { IsSingleInstance = value; } } public App() { IsSingleInstance = true; EnableVisualStyles = true; ShutdownStyle = ShutdownMode.AfterMainFormCloses; StartupNextInstance += SIApp_StartupNextInstance; } ////// We are responsible for creating the application's main form in this override. /// protected override void OnCreateMainForm() { // Create an instance of the main form and set it in the application; // but don't try to run it. MainForm = new FrmMain(); // We want to pass along the command-line arguments to this first instance // Allocate room in our string array int length = 0; ActivationArguments arguments = AppDomain.CurrentDomain.SetupInformation.ActivationArguments; if (arguments != null && arguments.ActivationData != null) length = arguments.ActivationData.Length; ((FrmMain)MainForm).Args = new string[length]; // And copy the arguments over to our form if (arguments != null && arguments.ActivationData != null) { arguments.ActivationData.CopyTo(((FrmMain)MainForm).Args, 0); } else ((FrmMain)MainForm).Args = new string[0]; } ////// This is called for additional instances. The application model will call this /// function, and terminate the additional instance when this returns. /// protected void SIApp_StartupNextInstance(object sender, StartupNextInstanceEventArgs eventArgs) { // Copy the arguments to a string array string[] args = new string[eventArgs.CommandLine.Count]; eventArgs.CommandLine.CopyTo(args, 0); // Create an argument array for the Invoke method object[] parameters = new object[2]; parameters[0] = MainForm; parameters[1] = args; // Need to use invoke to b/c this is being called from another thread. MainForm.Invoke(new ProcessParametersDelegate( ((FrmMain)MainForm).ProcessParameters), parameters); } }
The next Step to do is handle the MainApplicationEntryPoint. Here you use the just created Class and pass the Parameters from the ApplicationStartup (for ClickOnce-Apps, this Parameters are hold in the AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData)
Now we need to handle this Parameter in an (possible) existing Instance of the Application.
The Leak of this Solution is that it's not [easy/possible] to debug this stuff from the ClickOnceFramework, but you can write some Tests with common CommandlineParameters to see if this works.
Actually it should be much more easier in VB.NET... You won't need the workaround I've made there for C#.
ReplyDeleteIEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
DeleteIEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
ReplyDeleteor Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.
Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
ReplyDeleteData Science Tutorial
Data Science training in anna nagar
Data science training in jaya nagar
Data science training in pune
Data Science Training in Marathahalli
Data science training in kalyan nagar
Make money on kasino online and do not regret anything gamble casino with us Make money on kaino online and do not regret anything.
ReplyDeleteNice post I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great experience with this
ReplyDeletehardware and networking training in chennai
hardware and networking training in tambaram
xamarin training in chennai
xamarin training in tambaram
ios training in chennai
ios training in tambaram
iot training in chennai
iot training in tambaram
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging
ReplyDeletedata science training in chennai
data science training in porur
android training in chennai
android training in porur
devops training in chennai
devops training in porur
artificial intelligence training in chennai
artificial intelligence training in porur
Nice post I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great experience with this..
ReplyDeletejava training in chennai
java training in omr
aws training in chennai
aws training in omr
python training in chennai
python training in omr
selenium training in chennai
selenium training in omr
The manipulation, storage, and communication of digital information require proficient use of algorithms. Computer Science facilitates the usage of these algorithms. data science course syllabus
ReplyDeleteGood to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share.
ReplyDeletedata science course in India
Nice blog to read, Thanks for sharing this valuable article.
ReplyDeleteData Science Training Institute in Bangalore
Data Science Certification Course in Bangalore
no deposit bonus forex 2021 - takipçi satın al - takipçi satın al - takipçi satın al - tiktok takipçi satın al - instagram beğeni satın al - instagram beğeni satın al - google haritalara yer ekleme - btcturk güvenilir mi - izlenme-satin-al.com - numarasmsonay.com - borsagazete.com - takipcisatinals.com - izlenme-satin-al.com/youtube - google haritalara yer ekleme - altyapısız internet - mikrofiber havlu - forexbonus2020.com - tiktok jeton hilesi - tiktok beğeni satın al - microsoft word ücretsiz indir - misli apk indir - binance güvenilir mi - takipçi satın al - mikrofiber havlu - uc satın al - takipçi satın al - takipçi satın al - finanspedia.com
ReplyDeletetakipçi satın al
ReplyDeletetakipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
instagram takipçi satın al
smm panel
ReplyDeletesmm panel
faturalı hatta kredi
faturalı hatta kredi
instagram takipçi satın al
binance komisyon indirimi
binance indirim kodu
instagram takipçi satın al
tiktok jeton hilesi
Good content. You write beautiful things.
ReplyDeletevbet
sportsbet
mrbahis
hacklink
korsan taksi
mrbahis
vbet
hacklink
taksi