Click here to Skip to main content
15,896,526 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: How do we pass along arguments to another thread while preventing multiple instances? Pin
Mikzi7-Aug-06 12:09
Mikzi7-Aug-06 12:09 
QuestionBarcode Pin
omar el halwagy6-Aug-06 12:50
omar el halwagy6-Aug-06 12:50 
AnswerRe: Barcode Pin
Judah Gabriel Himango6-Aug-06 13:02
sponsorJudah Gabriel Himango6-Aug-06 13:02 
QuestionAuto refresh of referenced library... Pin
Shy Agam6-Aug-06 11:27
Shy Agam6-Aug-06 11:27 
AnswerRe: Auto refresh of referenced library... Pin
Judah Gabriel Himango6-Aug-06 11:42
sponsorJudah Gabriel Himango6-Aug-06 11:42 
GeneralRe: Auto refresh of referenced library... Pin
Shy Agam6-Aug-06 11:51
Shy Agam6-Aug-06 11:51 
GeneralRe: Auto refresh of referenced library... Pin
Judah Gabriel Himango6-Aug-06 12:45
sponsorJudah Gabriel Himango6-Aug-06 12:45 
GeneralRe: Auto refresh of referenced library... Pin
Shy Agam6-Aug-06 12:49
Shy Agam6-Aug-06 12:49 
GeneralRe: Auto refresh of referenced library... Pin
Judah Gabriel Himango6-Aug-06 13:01
sponsorJudah Gabriel Himango6-Aug-06 13:01 
GeneralRe: Auto refresh of referenced library... Pin
Shy Agam6-Aug-06 13:15
Shy Agam6-Aug-06 13:15 
QuestionC++ to C# Pin
t4ure4n6-Aug-06 11:22
t4ure4n6-Aug-06 11:22 
AnswerRe: C++ to C# Pin
Judah Gabriel Himango6-Aug-06 11:41
sponsorJudah Gabriel Himango6-Aug-06 11:41 
QuestionPaint a cell in DataGridView Pin
kalyanPaladugu6-Aug-06 10:56
kalyanPaladugu6-Aug-06 10:56 
AnswerRe: Paint a cell in DataGridView Pin
Judah Gabriel Himango6-Aug-06 11:38
sponsorJudah Gabriel Himango6-Aug-06 11:38 

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.