Bee Eee Blog

Tag: c# .Net

c# Command Line Arguments

by brian on Apr.14, 2008, under .NET, Uncategorized, c#, coding

Here’s how you access the command line arguments:

string[] argv = Environment.GetCommandLineArgs();
Leave a Comment : more...

Firing an event from within a thread. (At least one way)

by brian on Jan.16, 2008, under .NET, c#, coding

It took me forever to think of this easy method of firing an event from with a thread to the main thread.  In searching the web I found several complicated methods that either didn’t work or won’t worth the hassel.  But it turns out to be incredible simple and easy to do.  The only caveat is that the  event subscriber must be a System.Windows.Forms.Control or derived from one

Basically you just get the control target of the delegate and use it’s BeginInvoke or Invoke method and .Net does the rest.

        private void DoCommandFinished(Command cmd)
        {
            if ( null != CommandFinished )
            {
                System.Windows.Forms.Control c = CommandFinished.Target as System.Windows.Forms.Control;
                if (null != c)
                {
                    c.BeginInvoke(CommandFinished, cmd);
                }
            }
        }

I checked this method in my main window thread with the InvokeRequired function. It worked well.

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...