ProcessStart(textfile) focus issue

  • Thread starter Thread starter mp
  • Start date Start date
M

mp

just learning dotnet so i write a lot of debug lines to text file so i can
track where errors occur
Private Sub Logentry(ByVal strMsg As String)
File.AppendAllText("Path to debug file\Debug.txt", strMsg +
Environment.NewLine)
End Sub

the app is a vbnet app running inside autoCad, so it acts like i'm entering
autocad command inside autocad(autocad has focus)
Main app creates worker class that does the work
worker class creates utility class that has general functions used over
various projects
utility class provides logging etc

at end of program run utility class opens the text file to read the debug
log.

in worker class:
Protected Overrides Sub Finalize()
m_acadDoc = Nothing '<----destroy reference to acad document
m_acadApp = Nothing'<----destroy reference to acad application
m_util.OpenDebugLog() '<---ask util class to open debug log file in
notepad
m_util = Nothing'<----destroy reference to utility class

MyBase.Finalize()
End Sub


in the utility class:
Sub OpenDebugLog()
Process.Start(m_DebugFileName)
End Sub



when the file opens in notepad, notepad has focus and keyboard entry goes
into log file.

this didn't use to happen, the file just opened and keyboard focus was still
"in" autocad.

any ideas what i need to do to fix it?

thanks
mark
 
just learning dotnet so i write a lot of debug lines to text file so i can
track where errors occur
Private Sub Logentry(ByVal strMsg As String)
File.AppendAllText("Path to debug file\Debug.txt", strMsg +
Environment.NewLine)
End Sub

the app is a vbnet app running inside autoCad, so it acts like i'm entering
autocad command inside autocad(autocad has focus)
Main app creates worker class that does the work
worker class creates utility class that has general functions used over
various projects
utility class provides logging etc

at end of program run utility class opens the text file to read the debug
log.

in worker class:
Protected Overrides Sub Finalize()
m_acadDoc = Nothing '<----destroy reference to acad document
m_acadApp = Nothing'<----destroy reference to acad application
m_util.OpenDebugLog() '<---ask util class to open debug log file in
notepad
m_util = Nothing'<----destroy reference to utility class

MyBase.Finalize()
End Sub


in the utility class:
Sub OpenDebugLog()
Process.Start(m_DebugFileName)
End Sub



when the file opens in notepad, notepad has focus and keyboard entry goes
into log file.

this didn't use to happen, the file just opened and keyboard focus was still
"in" autocad.

any ideas what i need to do to fix it?

thanks
mark

So at some point you changed something and now focus goes to Notepad?

Just a guess, but did you used to pop up a message box after you opened
the text file in notepad? The act of opening a messagebox would have (I
believe) brought focus back to Autocad.
 
mp said:
just learning dotnet so i write a lot of debug lines to text file so
i can track where errors occur
Private Sub Logentry(ByVal strMsg As String)
File.AppendAllText("Path to debug file\Debug.txt", strMsg +
Environment.NewLine)
End Sub

As an aside, the string concatenation operator in VB.NET is "&", not "+".
 
Thanks, been bouncing between c# and vbnet trying to learn dotnet and in c#
i believe it changed to +
was always used to & , coming from vb6...will try to watch that.
thanks
mark
 
Back
Top