Resetting Environment.GetCommandLineArgs

  • Thread starter Thread starter Anatoly
  • Start date Start date
Is there a way to reset CommandLineArgs programmatically?

What do you mean by reset? The command line arguments are what they
are, set when the application is started.



Mattias
 
That's right, I started an app. from command line, then inside this app
I start a new instance of the same app. When this new instance starts,
for some reason it thinks it got started from command line even though I
start this new app on a new thread.

-Anatoly
 
Anatoly said:
That's right, I started an app. from command line, then inside this app
I start a new instance of the same app. When this new instance starts,
for some reason it thinks it got started from command line even though I
start this new app on a new thread.

How do you start an application on a "new thread"?!
 
Here is basically the code of New Thread:
(I've removed some of other misc settings I'm doing in pNewDocThread,
but this is the core code.)

'Start new thread.
Dim NewDocThread as New System.Threading.Thread(AddressOf pNewDocThread)
NewDocThread.Start()

Public Sub pNewDocThread()
Dim frm As New PTPApp
Application.Run(frm) 'Start new instance of App.
End Sub
 
Anatoly said:
Here is basically the code of New Thread:
(I've removed some of other misc settings I'm doing in pNewDocThread,
but this is the core code.)

'Start new thread.
Dim NewDocThread as New System.Threading.Thread(AddressOf pNewDocThread)
NewDocThread.Start()

Public Sub pNewDocThread()
Dim frm As New PTPApp
Application.Run(frm) 'Start new instance of App.
End Sub

Application.Run does not start a new instance. Application.run contains the
message loop keeping the Thread alive and handling the messages send to it.

This is not a new application (AKA process). It's only a new thread in the
same process.

How to pass arguments to threads:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcreatingthreads.asp
(see "Passing Data To Threads")

Within the thread, don't refer to the command line arguments but to the data
passed to the thread. If you want to have only one thread work with the
command line arguments, pass the arguments only to the first thread in sub main.

Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top