Re: Filewatch saga continues
- From: "Tom Leylan" <tleylan@xxxxxxxxxx>
- Date: Sat, 13 Jan 2007 02:27:20 -0500
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" <Rudy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CCFE8EAD-37D7-4E2F-B7C9-B29D593670E2@xxxxxxxxxxxxxxxx
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
.
- Follow-Ups:
- Re: Filewatch saga continues
- From: Rudy
- Re: Filewatch saga continues
- Prev by Date: Re: Difficult Question: Read/Modify file
- Next by Date: UML class library needed
- Previous by thread: Re: Difficult Question: Read/Modify file
- Next by thread: Re: Filewatch saga continues
- Index(es):
Relevant Pages
|