Click here to Skip to main content
15,905,875 members
Home / Discussions / C#
   

C#

 
AnswerRe: asynchronous programming and threads Pin
fmardani6-Aug-06 21:12
fmardani6-Aug-06 21:12 
QuestionInstaller Bootstrapper Pin
JacquesDP6-Aug-06 18:47
JacquesDP6-Aug-06 18:47 
Questionplease help me !!!!!!!! Pin
digitalangel6-Aug-06 18:33
digitalangel6-Aug-06 18:33 
AnswerRe: please help me !!!!!!!! Pin
JacquesDP6-Aug-06 18:44
JacquesDP6-Aug-06 18:44 
Questionhandles Pin
NasimKaziS6-Aug-06 18:23
NasimKaziS6-Aug-06 18:23 
AnswerRe: handles Pin
Ed.Poore6-Aug-06 22:20
Ed.Poore6-Aug-06 22:20 
Questionhow to retrieve a bit Pin
sarojkumarjena6-Aug-06 17:46
sarojkumarjena6-Aug-06 17:46 
AnswerRe: how to retrieve a bit Pin
stancrm6-Aug-06 20:03
stancrm6-Aug-06 20:03 
GeneralRe: how to retrieve a bit Pin
sarojkumarjena6-Aug-06 20:40
sarojkumarjena6-Aug-06 20:40 
GeneralRe: how to retrieve a bit Pin
stancrm6-Aug-06 20:58
stancrm6-Aug-06 20:58 
GeneralRe: how to retrieve a bit Pin
Divyang Mithaiwala7-Aug-06 2:46
Divyang Mithaiwala7-Aug-06 2:46 
Questiondifference between point and pointF Pin
KrunalC6-Aug-06 16:44
KrunalC6-Aug-06 16:44 
AnswerRe: difference between point and pointF Pin
Rob Graham6-Aug-06 16:55
Rob Graham6-Aug-06 16:55 
GeneralRe: difference between point and pointF Pin
KrunalC6-Aug-06 17:20
KrunalC6-Aug-06 17:20 
AnswerRe: difference between point and pointF Pin
Guffa6-Aug-06 21:29
Guffa6-Aug-06 21:29 
GeneralRe: difference between point and pointF Pin
KrunalC6-Aug-06 23:27
KrunalC6-Aug-06 23:27 
GeneralRe: difference between point and pointF Pin
Guffa6-Aug-06 23:31
Guffa6-Aug-06 23:31 
QuestionQuestion about DateTime or any other Data\Time object ... Pin
Yanshof6-Aug-06 13:10
Yanshof6-Aug-06 13:10 
AnswerRe: Question about DateTime or any other Data\Time object ... Pin
Shy Agam6-Aug-06 13:23
Shy Agam6-Aug-06 13:23 
GeneralRe: Question about DateTime or any other Data\Time object ... Pin
Yanshof6-Aug-06 13:31
Yanshof6-Aug-06 13:31 
AnswerRe: Question about DateTime or any other Data\Time object ... Pin
Ravi Bhavnani6-Aug-06 14:03
professionalRavi Bhavnani6-Aug-06 14:03 
QuestionHow do we pass along arguments to another thread while preventing multiple instances? Pin
Mikzi6-Aug-06 13:03
Mikzi6-Aug-06 13:03 
When a user opens a file associated with your program you may want the new instance to pass along the file to the first instance and exit. One problematic way of doing this is using the Visaul Basic MainForm.Invoke and StartupNextInstanceEventHandler. However, this library won't work with MONO/Linux and for some reason it connects to the network while invoking the thread, triggering a nasty firewall popup.

Is there any C# alternative or is it possible to improve on the code to avoid the network and mono problems? Please and Thank you!

using System;
using System.Windows.Forms;
using Microsoft.VisualBasic.ApplicationServices;

    class Program
    {
        [STAThread]
        static void Main(string[] args) { new App().Run(args); }

        class App : WindowsFormsApplicationBase
        {
            public App()
            {
                IsSingleInstance = EnableVisualStyles = true;
                ShutdownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses;
                StartupNextInstance += new StartupNextInstanceEventHandler(NextInstance);
            }

            protected override void OnCreateMainForm()
            {
                MainForm = new Form1();
                ((Form1)MainForm).Args = new string[CommandLineArgs.Count];
                CommandLineArgs.CopyTo(((Form1)MainForm).Args, 0);
            }

            protected void NextInstance(object sender, StartupNextInstanceEventArgs eventArgs)
            {
                string[] args = new string[eventArgs.CommandLine.Count];
                eventArgs.CommandLine.CopyTo(args, 0);
                MainForm.Invoke(new Form1.InstanceDelegate(((Form1)MainForm).processParameters), new object[] { MainForm, args });
            }
        }
    }

// In Form1 class:

public void processParameters(object sender, string[] args) 
{ 
    if (WindowState == FormWindowState.Minimized) 
        WindowState = FormWindowState.Normal; 
    if (args != null && args.Length != 0) 
        openFiles(args); // process args
} 


// Mikzi L. Freeman

AnswerRe: How do we pass along arguments to another thread while preventing multiple instances? Pin
Judah Gabriel Himango6-Aug-06 17:52
sponsorJudah Gabriel Himango6-Aug-06 17:52 
GeneralRe: How do we pass along arguments to another thread while preventing multiple instances? [modified] Pin
Mikzi7-Aug-06 0:26
Mikzi7-Aug-06 0:26 
GeneralRe: How do we pass along arguments to another thread while preventing multiple instances? Pin
mav.northwind7-Aug-06 3:21
mav.northwind7-Aug-06 3:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.