Re: Filewatch saga continues



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


.



Relevant Pages

  • Re: Playing AVI and MPEG using MCI
    ... "mciSendStringA" (ByVal lpstrCommand As String, ... Dim mlRet As Long ... Private Sub CenterObject ... If mlRet 0 Then ...
    (microsoft.public.vb.controls)
  • Change this Program
    ... Private sPathFrom As String ... Private Sub enableControl ... Dim oColor As OLE_COLOR ... Dim sPathTo As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Error when running vb app with FlexGrid control
    ... Private Sub cmdNetChange_Click ... On Error GoTo Command1_Click_Error ... Private Sub fnGetData(strParam0 As String, strParam1 As String, FLX As ... Dim rsADOObject As Recordset ...
    (microsoft.public.vb.general.discussion)
  • Sum in a dynamic query
    ... Private Sub Form_Open ... Dim db As Database, Tbl As TableDef ... Dim db As Database, qd As QueryDef, ctl As Control, s As String, Item As ...
    (comp.databases.ms-access)
  • Re: How to add/load records to combobox ?
    ... Dim rsCustomers As New ADODB.Recordset ... Private msCustomerIDsAs String ... Private Sub Combo1_Click ... Dim sSQL As String ...
    (microsoft.public.vb.controls)