473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Filewatch saga continues

Hello!

I posted this problem earlier. I wrote a quick test project, and I still
have the same problem. So I'm sure it's something in my code that I'm not
writing correctly.
Basicly I'm creating a file with abutton click from one application. The
other application has a file watch setup, when it see the newly created file,
it is prompted to open up a new form. But it locks up atn the very end of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better way of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class
Jan 13 '07 #1
14 1083
There are a couple of suggestions I would like to offer. The first is (when
you're testing things that don't work) is to eliminate the parts that don't
(or probably don't) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation. You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client application
doing when you think it has locked up? What do you want it to do? If I'm
not mistaken you'll find that your client app is running but without a form
on display. You are hiding the main form and showing a "Form1" (you should
rename that class) but it won't retain the focus the way you've written it.
It closes, the event handler is exited and frmFirst goes out of scope and is
destroyed.

I don't believe it has locked up I believe you can't see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I still
have the same problem. So I'm sure it's something in my code that I'm not
writing correctly.
Basicly I'm creating a file with abutton click from one application. The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class

Jan 13 '07 #2
Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try and
create a click event on the client ap, and open up the second form, and that
works fine. Iknow the form is locked up, because after a few seconds, I get
a non-responding on the window on my form. When I try to debug it, it doesnt
stop anywhere. Even when I put breka points, at the form load of the form 2,
form 1 and the file wacther. And to make things more intersting, after I get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:
There are a couple of suggestions I would like to offer. The first is (when
you're testing things that don't work) is to eliminate the parts that don't
(or probably don't) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation. You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client application
doing when you think it has locked up? What do you want it to do? If I'm
not mistaken you'll find that your client app is running but without a form
on display. You are hiding the main form and showing a "Form1" (you should
rename that class) but it won't retain the focus the way you've written it.
It closes, the event handler is exited and frmFirst goes out of scope and is
destroyed.

I don't believe it has locked up I believe you can't see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I still
have the same problem. So I'm sure it's something in my code that I'm not
writing correctly.
Basicly I'm creating a file with abutton click from one application. The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class


Jan 13 '07 #3
Hi!

AFAIK runs your AddressOf NKWatch_Created in an own thread and you can't (
more or less in praxis) use a form with the messagpump of the main thread.

What you can try (but i don't recommend) is a application.start(form2) to
create a new messagepump. Or better ( i think) queue the request and start
processing with a timer or a monitor. And think about the problem when more
then 1 file is created and you have a form already open.
Wolfgang

"Rudy" <Ru**@discussions.microsoft.comschrieb im Newsbeitrag
news:B4**********************************@microsof t.com...
Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:
>There are a couple of suggestions I would like to offer. The first is
(when
you're testing things that don't work) is to eliminate the parts that
don't
(or probably don't) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation.
You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces
involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do? If
I'm
not mistaken you'll find that your client app is running but without a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won't retain the focus the way you've written
it.
It closes, the event handler is exited and frmFirst goes out of scope and
is
destroyed.

I don't believe it has locked up I believe you can't see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microso ft.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I
still
have the same problem. So I'm sure it's something in my code that I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one application.
The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end
of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class



Jan 13 '07 #4
But if everything else is working fine then the only thing left is the form
right?

I just cut and pasted the code and had it out "file created" to the
immediate window and it works. So try not hiding "me" and see if the form
isn't sitting there waiting for you to do something. The
Application.DoEvents() isn't doing anything as far as I can tell either.
I'm still quite certain your program is running you just can't see the form
because you've hidden it. frmFirst doesn't have focus and it's destroyed
immediately.

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:B4**********************************@microsof t.com...
Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:
>There are a couple of suggestions I would like to offer. The first is
(when
you're testing things that don't work) is to eliminate the parts that
don't
(or probably don't) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation.
You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces
involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do? If
I'm
not mistaken you'll find that your client app is running but without a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won't retain the focus the way you've written
it.
It closes, the event handler is exited and frmFirst goes out of scope and
is
destroyed.

I don't believe it has locked up I believe you can't see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microso ft.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I
still
have the same problem. So I'm sure it's something in my code that I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one application.
The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end
of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class



Jan 13 '07 #5
Hi Wolfgang!
I think it your right. It has something to do with the threading. When I
watch the threads in my program, I get 2 threads with no name or location.
When I clcik to run it, it say no source code available.
I hate to use a timer, I have enough of those running. What do you suggest
I monitor with?

"Wolfgang Hauer" wrote:
Hi!

AFAIK runs your AddressOf NKWatch_Created in an own thread and you can't (
more or less in praxis) use a form with the messagpump of the main thread.

What you can try (but i don't recommend) is a application.start(form2) to
create a new messagepump. Or better ( i think) queue the request and start
processing with a timer or a monitor. And think about the problem when more
then 1 file is created and you have a form already open.
Wolfgang

"Rudy" <Ru**@discussions.microsoft.comschrieb im Newsbeitrag
news:B4**********************************@microsof t.com...
Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:
There are a couple of suggestions I would like to offer. The first is
(when
you're testing things that don't work) is to eliminate the parts that
don't
(or probably don't) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation.
You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces
involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do? If
I'm
not mistaken you'll find that your client app is running but without a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won't retain the focus the way you've written
it.
It closes, the event handler is exited and frmFirst goes out of scope and
is
destroyed.

I don't believe it has locked up I believe you can't see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I
still
have the same problem. So I'm sure it's something in my code that I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one application.
The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end
of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class


Jan 14 '07 #6
Hi Tom!

I took out the hide, no change. With out the application.doevents, my
screen comes up white. But you say it works on yours? Are you running 2003
or 2005. Could it be my application of Visual Studio. It's been on this
workstation since 2004.

What do you think?

Rudy

"Tom Leylan" wrote:
But if everything else is working fine then the only thing left is the form
right?

I just cut and pasted the code and had it out "file created" to the
immediate window and it works. So try not hiding "me" and see if the form
isn't sitting there waiting for you to do something. The
Application.DoEvents() isn't doing anything as far as I can tell either.
I'm still quite certain your program is running you just can't see the form
because you've hidden it. frmFirst doesn't have focus and it's destroyed
immediately.

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:B4**********************************@microsof t.com...
Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:
There are a couple of suggestions I would like to offer. The first is
(when
you're testing things that don't work) is to eliminate the parts that
don't
(or probably don't) impact the problem. You could for instance still see
the problem even if you eliminate the "server app" from the equation.
You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces
involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do? If
I'm
not mistaken you'll find that your client app is running but without a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won't retain the focus the way you've written
it.
It closes, the event handler is exited and frmFirst goes out of scope and
is
destroyed.

I don't believe it has locked up I believe you can't see that it is still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microsof t.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I
still
have the same problem. So I'm sure it's something in my code that I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one application.
The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end
of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class


Jan 14 '07 #7
Hi Guys!

OK. So I think I got it to work.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
frmFirst.Show()
Application.Run(FrmFirst)
End Sub
End Class
My question is this the best way. The form in question will only be up for
15 -20 seconds. The the user quits out. It seems to work great! I just want
to make sure I might not get in some kind of issue down the line.

Thanks for all your help!
Rudy

Ta
"Rudy" wrote:
Hi Tom!

I took out the hide, no change. With out the application.doevents, my
screen comes up white. But you say it works on yours? Are you running 2003
or 2005. Could it be my application of Visual Studio. It's been on this
workstation since 2004.

What do you think?

Rudy

"Tom Leylan" wrote:
But if everything else is working fine then the only thing left is the form
right?

I just cut and pasted the code and had it out "file created" to the
immediate window and it works. So try not hiding "me" and see if the form
isn't sitting there waiting for you to do something. The
Application.DoEvents() isn't doing anything as far as I can tell either.
I'm still quite certain your program is running you just can't see the form
because you've hidden it. frmFirst doesn't have focus and it's destroyed
immediately.

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:B4**********************************@microsof t.com...
Hi Tom!
>
Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send it
Microsoft. I get a meesage form CS 2003 that says "There is no source code
avaiable for the current location"
>
So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.
>
Any other thoughts?
>
Thanks!
Rudy
>
"Tom Leylan" wrote:
>
>There are a couple of suggestions I would like to offer. The first is
>(when
>you're testing things that don't work) is to eliminate the parts that
>don't
>(or probably don't) impact the problem. You could for instance still see
>the problem even if you eliminate the "server app" from the equation.
>You
>can simply copy a file into the folder and that will work as well. The
>reason is that you're trying to narrow things down, the more pieces
>involved
>the harder that will be.
>>
>And don't create and show a form when you're not certain the watcher is
>working. Again you can output a simple message "I see it" to an output
>window and reduce the number of suspicious spots even more.
>>
>The next suggestion is to use the debugger. What is your client
>application
>doing when you think it has locked up? What do you want it to do? If
>I'm
>not mistaken you'll find that your client app is running but without a
>form
>on display. You are hiding the main form and showing a "Form1" (you
>should
>rename that class) but it won't retain the focus the way you've written
>it.
>It closes, the event handler is exited and frmFirst goes out of scope and
>is
>destroyed.
>>
>I don't believe it has locked up I believe you can't see that it is still
>running.
>>
>Tom
>>
>>
>"Rudy" <Ru**@discussions.microsoft.comwrote in message
>news:CC**********************************@microso ft.com...
Hello!
>
I posted this problem earlier. I wrote a quick test project, and I
still
have the same problem. So I'm sure it's something in my code that I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one application.
The
other application has a file watch setup, when it see the newly created
file,
it is prompted to open up a new form. But it locks up atn the very end
of
opening up the form.
>
Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!
>
Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO
>
Public Class Form1
Inherits System.Windows.Forms.Form
>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
>
Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub
>
End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form
>
Public NKWatch As New FileSystemWatcher
>
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
>
AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub
>
Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class
>>
>>
>>
Jan 14 '07 #8
I have to say that I doubt your solution is the best way but there is no way
to tell unless we know what are you ultimately trying to do. What is point
of the pop-up form?

Again you're creating a temporary form (with a very short lifespan) and
displaying it non-modally. Is it supposed to take over for the main form?
Try this and see if some sort of dialog window would suit your needs.
Obviously you can fancy up the form but this demonstrates it can display
one.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)

Dim frm As Form = New Form()
With frm
.Text = "File Created"
.ShowDialog()
End With

End Sub
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:C1**********************************@microsof t.com...
Hi Guys!

OK. So I think I got it to work.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
frmFirst.Show()
Application.Run(FrmFirst)
End Sub
End Class
My question is this the best way. The form in question will only be up
for
15 -20 seconds. The the user quits out. It seems to work great! I just
want
to make sure I might not get in some kind of issue down the line.

Thanks for all your help!
Rudy

Ta
"Rudy" wrote:
>Hi Tom!

I took out the hide, no change. With out the application.doevents, my
screen comes up white. But you say it works on yours? Are you running
2003
or 2005. Could it be my application of Visual Studio. It's been on this
workstation since 2004.

What do you think?

Rudy

"Tom Leylan" wrote:
But if everything else is working fine then the only thing left is the
form
right?

I just cut and pasted the code and had it out "file created" to the
immediate window and it works. So try not hiding "me" and see if the
form
isn't sitting there waiting for you to do something. The
Application.DoEvents() isn't doing anything as far as I can tell
either.
I'm still quite certain your program is running you just can't see the
form
because you've hidden it. frmFirst doesn't have focus and it's
destroyed
immediately.

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:B4**********************************@microsof t.com...
Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly,
but
having a s simple message box displayed. So I'm good there. I did
try and
create a click event on the client ap, and open up the second form,
and
that
works fine. Iknow the form is locked up, because after a few
seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the
form
2,
form 1 and the file wacther. And to make things more intersting,
after I
get
the window that ask if I want to stop this program, do you want to
send it
Microsoft. I get a meesage form CS 2003 that says "There is no source
code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app,
eleminating
everything elses in my real program. I hope if I can get this to
work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:

There are a couple of suggestions I would like to offer. The first
is
(when
you're testing things that don't work) is to eliminate the parts
that
don't
(or probably don't) impact the problem. You could for instance
still see
the problem even if you eliminate the "server app" from the
equation.
You
can simply copy a file into the folder and that will work as well.
The
reason is that you're trying to narrow things down, the more pieces
involved
the harder that will be.

And don't create and show a form when you're not certain the watcher
is
working. Again you can output a simple message "I see it" to an
output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do?
If
I'm
not mistaken you'll find that your client app is running but without
a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won't retain the focus the way you've
written
it.
It closes, the event handler is exited and frmFirst goes out of
scope and
is
destroyed.

I don't believe it has locked up I believe you can't see that it is
still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@microso ft.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and
I
still
have the same problem. So I'm sure it's something in my code that
I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one
application.
The
other application has a file watch setup, when it see the newly
created
file,
it is prompted to open up a new form. But it locks up atn the
very end
of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a
better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class


Jan 14 '07 #9
OOPs:

application.Run(...) is correct. And one hint: In the event the new created
file is maybe still open, so you can't open it. So bilding a queue is your
friend.
And the more i think about your problem i would use a timer and check the
queue. And don't forget to lock your queue when accessing.

Wolfgang
"Wolfgang Hauer" <ha***@DELETETHATsysdat.atschrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi!

AFAIK runs your AddressOf NKWatch_Created in an own thread and you can't
( more or less in praxis) use a form with the messagpump of the main
thread.

What you can try (but i don't recommend) is a application.start(form2) to
create a new messagepump. Or better ( i think) queue the request and start
processing with a timer or a monitor. And think about the problem when
more then 1 file is created and you have a form already open.
Wolfgang

"Rudy" <Ru**@discussions.microsoft.comschrieb im Newsbeitrag
news:B4**********************************@microsof t.com...
>Hi Tom!

Thnks for the suggestions. I did make sure my watch works properly, but
having a s simple message box displayed. So I'm good there. I did try
and
create a click event on the client ap, and open up the second form, and
that
works fine. Iknow the form is locked up, because after a few seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the form
2,
form 1 and the file wacther. And to make things more intersting, after I
get
the window that ask if I want to stop this program, do you want to send
it
Microsoft. I get a meesage form CS 2003 that says "There is no source
code
avaiable for the current location"

So I'm not sure sure where to look. I wrote this simple app, eleminating
everything elses in my real program. I hope if I can get this to work, I
might be able to fix my real application.

Any other thoughts?

Thanks!
Rudy

"Tom Leylan" wrote:
>>There are a couple of suggestions I would like to offer. The first is
(when
you're testing things that don't work) is to eliminate the parts that
don't
(or probably don't) impact the problem. You could for instance still
see
the problem even if you eliminate the "server app" from the equation.
You
can simply copy a file into the folder and that will work as well. The
reason is that you're trying to narrow things down, the more pieces
involved
the harder that will be.

And don't create and show a form when you're not certain the watcher is
working. Again you can output a simple message "I see it" to an output
window and reduce the number of suspicious spots even more.

The next suggestion is to use the debugger. What is your client
application
doing when you think it has locked up? What do you want it to do? If
I'm
not mistaken you'll find that your client app is running but without a
form
on display. You are hiding the main form and showing a "Form1" (you
should
rename that class) but it won't retain the focus the way you've written
it.
It closes, the event handler is exited and frmFirst goes out of scope
and is
destroyed.

I don't believe it has locked up I believe you can't see that it is
still
running.

Tom
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:CC**********************************@micros oft.com...
Hello!

I posted this problem earlier. I wrote a quick test project, and I
still
have the same problem. So I'm sure it's something in my code that I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one application.
The
other application has a file watch setup, when it see the newly
created
file,
it is prompted to open up a new form. But it locks up atn the very
end of
opening up the form.

Take a look at my code, what am I doing wrong? Or is there a better
way
of
doing this? Thanks!

Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub

End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form

Public NKWatch As New FileSystemWatcher

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class


Jan 14 '07 #10
Hi Tom!

For this form, ShowDialog wouldn't work. I have values that are taken from
other forms, and populated into this one. I also have several connections
going on to SQL . The form is only up for 15 to 20 seconds, but there is alot
of stuff goin on in that time frame. After the form is closed, it will be
opened again from the server application in about 30 seconds to a minute, and
then the whole process starts. I'll do alot of testing on thsi, but I think
for this need, this is the way to go.

But I do beleive the ShowDialog would work on other formsI have. I want to
you custom messagboxes that pop up for 3-5 seconds then go out. I think that
would be perfect for that.

I certainly learned alot about managing forms, and have alot of
re-programming to do to make my program better. Thanks for all your help on
this!

Rudy

"Tom Leylan" wrote:
I have to say that I doubt your solution is the best way but there is no way
to tell unless we know what are you ultimately trying to do. What is point
of the pop-up form?

Again you're creating a temporary form (with a very short lifespan) and
displaying it non-modally. Is it supposed to take over for the main form?
Try this and see if some sort of dialog window would suit your needs.
Obviously you can fancy up the form but this demonstrates it can display
one.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)

Dim frm As Form = New Form()
With frm
.Text = "File Created"
.ShowDialog()
End With

End Sub
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:C1**********************************@microsof t.com...
Hi Guys!

OK. So I think I got it to work.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
frmFirst.Show()
Application.Run(FrmFirst)
End Sub
End Class
My question is this the best way. The form in question will only be up
for
15 -20 seconds. The the user quits out. It seems to work great! I just
want
to make sure I might not get in some kind of issue down the line.

Thanks for all your help!
Rudy

Ta
"Rudy" wrote:
Hi Tom!

I took out the hide, no change. With out the application.doevents, my
screen comes up white. But you say it works on yours? Are you running
2003
or 2005. Could it be my application of Visual Studio. It's been on this
workstation since 2004.

What do you think?

Rudy

"Tom Leylan" wrote:

But if everything else is working fine then the only thing left is the
form
right?

I just cut and pasted the code and had it out "file created" to the
immediate window and it works. So try not hiding "me" and see if the
form
isn't sitting there waiting for you to do something. The
Application.DoEvents() isn't doing anything as far as I can tell
either.
I'm still quite certain your program is running you just can't see the
form
because you've hidden it. frmFirst doesn't have focus and it's
destroyed
immediately.

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:B4**********************************@microsof t.com...
Hi Tom!
>
Thnks for the suggestions. I did make sure my watch works properly,
but
having a s simple message box displayed. So I'm good there. I did
try and
create a click event on the client ap, and open up the second form,
and
that
works fine. Iknow the form is locked up, because after a few
seconds, I
get
a non-responding on the window on my form. When I try to debug it, it
doesnt
stop anywhere. Even when I put breka points, at the form load of the
form
2,
form 1 and the file wacther. And to make things more intersting,
after I
get
the window that ask if I want to stop this program, do you want to
send it
Microsoft. I get a meesage form CS 2003 that says "There is no source
code
avaiable for the current location"
>
So I'm not sure sure where to look. I wrote this simple app,
eleminating
everything elses in my real program. I hope if I can get this to
work, I
might be able to fix my real application.
>
Any other thoughts?
>
Thanks!
Rudy
>
"Tom Leylan" wrote:
>
>There are a couple of suggestions I would like to offer. The first
>is
>(when
>you're testing things that don't work) is to eliminate the parts
>that
>don't
>(or probably don't) impact the problem. You could for instance
>still see
>the problem even if you eliminate the "server app" from the
>equation.
>You
>can simply copy a file into the folder and that will work as well.
>The
>reason is that you're trying to narrow things down, the more pieces
>involved
>the harder that will be.
>>
>And don't create and show a form when you're not certain the watcher
>is
>working. Again you can output a simple message "I see it" to an
>output
>window and reduce the number of suspicious spots even more.
>>
>The next suggestion is to use the debugger. What is your client
>application
>doing when you think it has locked up? What do you want it to do?
>If
>I'm
>not mistaken you'll find that your client app is running but without
>a
>form
>on display. You are hiding the main form and showing a "Form1" (you
>should
>rename that class) but it won't retain the focus the way you've
>written
>it.
>It closes, the event handler is exited and frmFirst goes out of
>scope and
>is
>destroyed.
>>
>I don't believe it has locked up I believe you can't see that it is
>still
>running.
>>
>Tom
>>
>>
>"Rudy" <Ru**@discussions.microsoft.comwrote in message
>news:CC**********************************@microso ft.com...
Hello!
>
I posted this problem earlier. I wrote a quick test project, and
I
still
have the same problem. So I'm sure it's something in my code that
I'm
not
writing correctly.
Basicly I'm creating a file with abutton click from one
application.
The
other application has a file watch setup, when it see the newly
created
file,
it is prompted to open up a new form. But it locks up atn the
very end
of
opening up the form.
>
Take a look at my code, what am I doing wrong? Or is there a
better
way
of
doing this? Thanks!
>
Rudy
SERVER APPLICATION
<BEGIN CODE>
Imports System.IO
>
Public Class Form1
Inherits System.Windows.Forms.Form
>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles Button1.Click
>
Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "C:\test\watch"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
End Sub
>
End Class
CLIENT APPLICATION with from that has watch process
<BEGIN CODE>
Imports System.IO
Public Class Form2
Inherits System.Windows.Forms.Form
>
Public NKWatch As New FileSystemWatcher
>
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles MyBase.Load
>
AddHandler NKWatch.Created, AddressOf NKWatch_Created
Try
NKWatch.Path = "C:\test\watch"
NKWatch.Filter = "*.out"
NKWatch.IncludeSubdirectories = False
NKWatch.EnableRaisingEvents = True
Catch ERR As Exception
MessageBox.Show(ERR.Message)
End Try
End Sub
>
Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim frmFirst As New Form1
Me.Hide()
frmFirst.Show()
Application.DoEvents()
End Sub
End Class
>>
>>
>>



Jan 14 '07 #11
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:4D**********************************@microsof t.com...
For this form, ShowDialog wouldn't work. I have values that are taken
from
other forms, and populated into this one. I also have several connections
going on to SQL . The form is only up for 15 to 20 seconds, but there is
alot
of stuff goin on in that time frame. After the form is closed, it will be
opened again from the server application in about 30 seconds to a minute,
and
then the whole process starts. I'll do alot of testing on thsi, but I
think
for this need, this is the way to go.
Rudy:

It was trickier than I thought due in part (in so far as I can tell) to the
thread-safe features added to VS2005. Starting from here
http://msdn2.microsoft.com/en-us/library/ms171728.aspx I managed to create a
pop-up (non-modal) window that displays "file created" in a label which then
disappears when a set number of seconds elapses.

I might be able to cut enough code in to a reply to make it make sense
without boring everybody... let's see.

Public Class <your main form>

Private pop As PopUp
Private poptimer As System.Windows.Forms.Timer

Delegate Sub PopCallback()

Private WithEvents worker1 As BackgroundWorker

Public NKWatch As FileSystemWatcher

PopUp is a form which will display, poptimer is a timer to make it go away,
PopCallback is used by the NKWatch event handler worker1 is a
BackgroundWorker (per the instructions found on the MSDN site) and you know
about NKWatch.

Inside <your main forminitialization add the following. Notice I've only
set up a single pop-up form. If you need more than one you'll have to do a
bit more work. In any case this pop is ready for use but not visible until
a file is detected. I've set the timer to close it after 2 seconds.

pop = New PopUp

With pop
.Owner = Me
.TopMost = True
.Visible = False
End With

poptimer = New System.Windows.Forms.Timer
With poptimer
.Interval = 2000
.Enabled = False
End With

AddHandler poptimer.Tick, AddressOf PopHandler

worker1 = New BackgroundWorker

NKWatch = New FileSystemWatcher

With NKWatch
.Path = "C:\"
.Filter = "*.txt"
.IncludeSubdirectories = False
.EnableRaisingEvents = True
End With

AddHandler NKWatch.Created, AddressOf NKWatch_Created

You already have the event handler so simply add the code within this.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
FileSystemEventArgs)
Me.worker1.RunWorkerAsync()
End Sub

Add this event handler which the article describes will be called when the
RunWorker completed event is called.

Private Sub PopWorkerCompleted(ByVal sender As Object, ByVal e As
RunWorkerCompletedEventArgs) Handles worker1.RunWorkerCompleted
Dim p As New PopCallback(AddressOf PopShow)
Me.Invoke(p, New Object() {})
End Sub
Add PopShow to make the popup window appear and PopHandler to make it
disappear.

Private Sub PopShow()
pop.Visible = True
poptimer.Start()
End Sub

Private Sub PopHandler(ByVal myObject As Object, ByVal myEventArgs As
EventArgs)
pop.Visible = False
poptimer.Stop()
End Sub

Clearly you'll have to futz with it somewhat and I've mixed my AddHandler
and Handles syntax (I prefer AddHandler) but hopefully this points you in
the right direction.

Tom
Jan 14 '07 #12
Hi Tom!

WOW!! That is cool! So I'm trying to work through this. I'm confused
where I'm grabbing "BackgroundWorker" from. As in "Private WithEvents worker1
as BackgroundWorker". What namespace am I importing, or am I missing
something?

Thanks!

Rudy

"Tom Leylan" wrote:
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:4D**********************************@microsof t.com...
For this form, ShowDialog wouldn't work. I have values that are taken
from
other forms, and populated into this one. I also have several connections
going on to SQL . The form is only up for 15 to 20 seconds, but there is
alot
of stuff goin on in that time frame. After the form is closed, it will be
opened again from the server application in about 30 seconds to a minute,
and
then the whole process starts. I'll do alot of testing on thsi, but I
think
for this need, this is the way to go.

Rudy:

It was trickier than I thought due in part (in so far as I can tell) to the
thread-safe features added to VS2005. Starting from here
http://msdn2.microsoft.com/en-us/library/ms171728.aspx I managed to create a
pop-up (non-modal) window that displays "file created" in a label which then
disappears when a set number of seconds elapses.

I might be able to cut enough code in to a reply to make it make sense
without boring everybody... let's see.

Public Class <your main form>

Private pop As PopUp
Private poptimer As System.Windows.Forms.Timer

Delegate Sub PopCallback()

Private WithEvents worker1 As BackgroundWorker

Public NKWatch As FileSystemWatcher

PopUp is a form which will display, poptimer is a timer to make it go away,
PopCallback is used by the NKWatch event handler worker1 is a
BackgroundWorker (per the instructions found on the MSDN site) and you know
about NKWatch.

Inside <your main forminitialization add the following. Notice I've only
set up a single pop-up form. If you need more than one you'll have to do a
bit more work. In any case this pop is ready for use but not visible until
a file is detected. I've set the timer to close it after 2 seconds.

pop = New PopUp

With pop
.Owner = Me
.TopMost = True
.Visible = False
End With

poptimer = New System.Windows.Forms.Timer
With poptimer
.Interval = 2000
.Enabled = False
End With

AddHandler poptimer.Tick, AddressOf PopHandler

worker1 = New BackgroundWorker

NKWatch = New FileSystemWatcher

With NKWatch
.Path = "C:\"
.Filter = "*.txt"
.IncludeSubdirectories = False
.EnableRaisingEvents = True
End With

AddHandler NKWatch.Created, AddressOf NKWatch_Created

You already have the event handler so simply add the code within this.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
FileSystemEventArgs)
Me.worker1.RunWorkerAsync()
End Sub

Add this event handler which the article describes will be called when the
RunWorker completed event is called.

Private Sub PopWorkerCompleted(ByVal sender As Object, ByVal e As
RunWorkerCompletedEventArgs) Handles worker1.RunWorkerCompleted
Dim p As New PopCallback(AddressOf PopShow)
Me.Invoke(p, New Object() {})
End Sub
Add PopShow to make the popup window appear and PopHandler to make it
disappear.

Private Sub PopShow()
pop.Visible = True
poptimer.Start()
End Sub

Private Sub PopHandler(ByVal myObject As Object, ByVal myEventArgs As
EventArgs)
pop.Visible = False
poptimer.Stop()
End Sub

Clearly you'll have to futz with it somewhat and I've mixed my AddHandler
and Handles syntax (I prefer AddHandler) but hopefully this points you in
the right direction.

Tom
Jan 15 '07 #13
Well Rudy... there is the "help" system but it's also a fair guess it is
included in one of the 4 listed in the code included on the MSDN page and it
won't be System.Windows.Forms.
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:46**********************************@microsof t.com...
Hi Tom!

WOW!! That is cool! So I'm trying to work through this. I'm confused
where I'm grabbing "BackgroundWorker" from. As in "Private WithEvents
worker1
as BackgroundWorker". What namespace am I importing, or am I missing
something?

Thanks!

Rudy

"Tom Leylan" wrote:
>"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:4D**********************************@microso ft.com...
For this form, ShowDialog wouldn't work. I have values that are taken
from
other forms, and populated into this one. I also have several
connections
going on to SQL . The form is only up for 15 to 20 seconds, but there
is
alot
of stuff goin on in that time frame. After the form is closed, it will
be
opened again from the server application in about 30 seconds to a
minute,
and
then the whole process starts. I'll do alot of testing on thsi, but I
think
for this need, this is the way to go.

Rudy:

It was trickier than I thought due in part (in so far as I can tell) to
the
thread-safe features added to VS2005. Starting from here
http://msdn2.microsoft.com/en-us/library/ms171728.aspx I managed to
create a
pop-up (non-modal) window that displays "file created" in a label which
then
disappears when a set number of seconds elapses.

I might be able to cut enough code in to a reply to make it make sense
without boring everybody... let's see.

Public Class <your main form>

Private pop As PopUp
Private poptimer As System.Windows.Forms.Timer

Delegate Sub PopCallback()

Private WithEvents worker1 As BackgroundWorker

Public NKWatch As FileSystemWatcher

PopUp is a form which will display, poptimer is a timer to make it go
away,
PopCallback is used by the NKWatch event handler worker1 is a
BackgroundWorker (per the instructions found on the MSDN site) and you
know
about NKWatch.

Inside <your main forminitialization add the following. Notice I've
only
set up a single pop-up form. If you need more than one you'll have to do
a
bit more work. In any case this pop is ready for use but not visible
until
a file is detected. I've set the timer to close it after 2 seconds.

pop = New PopUp

With pop
.Owner = Me
.TopMost = True
.Visible = False
End With

poptimer = New System.Windows.Forms.Timer
With poptimer
.Interval = 2000
.Enabled = False
End With

AddHandler poptimer.Tick, AddressOf PopHandler

worker1 = New BackgroundWorker

NKWatch = New FileSystemWatcher

With NKWatch
.Path = "C:\"
.Filter = "*.txt"
.IncludeSubdirectories = False
.EnableRaisingEvents = True
End With

AddHandler NKWatch.Created, AddressOf NKWatch_Created

You already have the event handler so simply add the code within this.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
FileSystemEventArgs)
Me.worker1.RunWorkerAsync()
End Sub

Add this event handler which the article describes will be called when
the
RunWorker completed event is called.

Private Sub PopWorkerCompleted(ByVal sender As Object, ByVal e As
RunWorkerCompletedEventArgs) Handles worker1.RunWorkerCompleted
Dim p As New PopCallback(AddressOf PopShow)
Me.Invoke(p, New Object() {})
End Sub
Add PopShow to make the popup window appear and PopHandler to make it
disappear.

Private Sub PopShow()
pop.Visible = True
poptimer.Start()
End Sub

Private Sub PopHandler(ByVal myObject As Object, ByVal myEventArgs As
EventArgs)
pop.Visible = False
poptimer.Stop()
End Sub

Clearly you'll have to futz with it somewhat and I've mixed my AddHandler
and Handles syntax (I prefer AddHandler) but hopefully this points you in
the right direction.

Tom

Jan 15 '07 #14
Hi Tom!
I did look at the help, But I'll take a closer look. I'll have to tweak the
code a little. But I definitely appreciate all your help on this. I'll have
to look in that safe threading as well. I have VS 2005 for work, and VS 2003
at home. I haven't upgraded yet. I really should, because I'm starting to
really like 2005, even though I don't program at work as much as I do at home.

Thanks again for all your help on this, I have really leanred alot from this.

Rudy

"Tom Leylan" wrote:
Well Rudy... there is the "help" system but it's also a fair guess it is
included in one of the 4 listed in the code included on the MSDN page and it
won't be System.Windows.Forms.
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:46**********************************@microsof t.com...
Hi Tom!

WOW!! That is cool! So I'm trying to work through this. I'm confused
where I'm grabbing "BackgroundWorker" from. As in "Private WithEvents
worker1
as BackgroundWorker". What namespace am I importing, or am I missing
something?

Thanks!

Rudy

"Tom Leylan" wrote:
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:4D**********************************@microsof t.com...

For this form, ShowDialog wouldn't work. I have values that are taken
from
other forms, and populated into this one. I also have several
connections
going on to SQL . The form is only up for 15 to 20 seconds, but there
is
alot
of stuff goin on in that time frame. After the form is closed, it will
be
opened again from the server application in about 30 seconds to a
minute,
and
then the whole process starts. I'll do alot of testing on thsi, but I
think
for this need, this is the way to go.

Rudy:

It was trickier than I thought due in part (in so far as I can tell) to
the
thread-safe features added to VS2005. Starting from here
http://msdn2.microsoft.com/en-us/library/ms171728.aspx I managed to
create a
pop-up (non-modal) window that displays "file created" in a label which
then
disappears when a set number of seconds elapses.

I might be able to cut enough code in to a reply to make it make sense
without boring everybody... let's see.

Public Class <your main form>

Private pop As PopUp
Private poptimer As System.Windows.Forms.Timer

Delegate Sub PopCallback()

Private WithEvents worker1 As BackgroundWorker

Public NKWatch As FileSystemWatcher

PopUp is a form which will display, poptimer is a timer to make it go
away,
PopCallback is used by the NKWatch event handler worker1 is a
BackgroundWorker (per the instructions found on the MSDN site) and you
know
about NKWatch.

Inside <your main forminitialization add the following. Notice I've
only
set up a single pop-up form. If you need more than one you'll have to do
a
bit more work. In any case this pop is ready for use but not visible
until
a file is detected. I've set the timer to close it after 2 seconds.

pop = New PopUp

With pop
.Owner = Me
.TopMost = True
.Visible = False
End With

poptimer = New System.Windows.Forms.Timer
With poptimer
.Interval = 2000
.Enabled = False
End With

AddHandler poptimer.Tick, AddressOf PopHandler

worker1 = New BackgroundWorker

NKWatch = New FileSystemWatcher

With NKWatch
.Path = "C:\"
.Filter = "*.txt"
.IncludeSubdirectories = False
.EnableRaisingEvents = True
End With

AddHandler NKWatch.Created, AddressOf NKWatch_Created

You already have the event handler so simply add the code within this.

Public Sub NKWatch_Created(ByVal sender As Object, ByVal e As
FileSystemEventArgs)
Me.worker1.RunWorkerAsync()
End Sub

Add this event handler which the article describes will be called when
the
RunWorker completed event is called.

Private Sub PopWorkerCompleted(ByVal sender As Object, ByVal e As
RunWorkerCompletedEventArgs) Handles worker1.RunWorkerCompleted
Dim p As New PopCallback(AddressOf PopShow)
Me.Invoke(p, New Object() {})
End Sub
Add PopShow to make the popup window appear and PopHandler to make it
disappear.

Private Sub PopShow()
pop.Visible = True
poptimer.Start()
End Sub

Private Sub PopHandler(ByVal myObject As Object, ByVal myEventArgs As
EventArgs)
pop.Visible = False
poptimer.Stop()
End Sub

Clearly you'll have to futz with it somewhat and I've mixed my AddHandler
and Handles syntax (I prefer AddHandler) but hopefully this points you in
the right direction.

Tom


Jan 15 '07 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chris P. | last post by:
Hi. I've made a program that logs onto a telnet server, enters a command, and then creates a list of useful information out of the information that is dumped to the screen as a result of the...
1
by: leegold2 | last post by:
I've noticed for a long time with Netscape and Mozilla. Given a page with Javascript - at least the code I'm testing - the page will render correctly but continues to load until I press stop. When...
9
by: Lynn | last post by:
I have a very simple Access database containing a single table. It is part of a data-logger were I INSERT a new record once every ten seconds. Three times a day I DELETE records older than one...
0
by: Timo | last post by:
My (intranet) aspx page finishes loading but the progress bar continues to advance very very very slowly, i.e. a new chunk on the bar is added 10 seconds or so, and then progress bar stops about...
2
by: ENathan | last post by:
I have a public sub in a class that does something like: If ValuesChanged() Then UpdateDatabase End If ValuesChanged and UpdateDatabase are Private functions within the class. My problem...
7
by: Joe | last post by:
I've tracked the performance issue down to a single class. This class derives from CollectionBase and stores a basic value type such as string, int, double, etc... I also store the type itself...
3
by: Rudy | last post by:
Hello all! This is what I want to do, looking the for the best way to do this. I have a text file that gets created and placed in a folder. I would like to have a watch for that file when it pops...
0
by: Rudy | last post by:
Hello all! I am having problem wih filewatch, I think. Basicly I have a trigger that creates a file. Filewatch looks for a modified date on the file, than when it see's it, it should pop up a...
6
by: oliver | last post by:
Hey Everyone, This is probably going to sound like a bit of a stupid question - but why does (in the following code) the script just continue to run past the raw_input, when the user hasn't...
3
by: =?Utf-8?B?UnVkeQ==?= | last post by:
Hello All! I may have posted this problem before, but it was awhile ago. I'm working in VS 2003. I have 10 file watch process going. It seems that I can only about 6or 7 to run at the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.