locked
calling a filewatch process RRS feed

  • Question

  •  

    Hello all!

     

    I have a file watch process.

    Private Sub OutWatcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles OutWatcher.Created

    RefreshMain()

    End Sub

     

    Now I would like to call this in another place in my code.

    OutWatcher_Created(sender,e)

    But this balks at the "e".  I'm not sure what I'm suppose to put there? ByVal e As System.IO.FileSystemEventArgs, what is this exactly?

     

    Thanks!

     

    Rudy

    Thursday, January 31, 2008 5:21 PM

Answers

  • sender is the object which sends the event itself, e gives some additional information about the event. In your case the e members would contain eg the name and the full path of the file created.

    if you don't use sender and e in your code, you could call the function "manually" by

    OutWatcher_Created(Nothing, Nothing) or OutWatcher_Created(OutWatcher, Nothing) if you want to work with the sender object.

    but for keeping your code manageable i would suggest to create a own sub for this and call this sub from within the event and also somewhere elso in your code, because it could be confusing to call event handlers manually when actually no event really happend.

    Why can't you just call RefreshMain() directly instead of trying to call OutWatcher_Created from the other places in your code?

    Thursday, January 31, 2008 5:39 PM

All replies

  • sender is the object which sends the event itself, e gives some additional information about the event. In your case the e members would contain eg the name and the full path of the file created.

    if you don't use sender and e in your code, you could call the function "manually" by

    OutWatcher_Created(Nothing, Nothing) or OutWatcher_Created(OutWatcher, Nothing) if you want to work with the sender object.

    but for keeping your code manageable i would suggest to create a own sub for this and call this sub from within the event and also somewhere elso in your code, because it could be confusing to call event handlers manually when actually no event really happend.

    Why can't you just call RefreshMain() directly instead of trying to call OutWatcher_Created from the other places in your code?

    Thursday, January 31, 2008 5:39 PM
  • Hi Brainwasher

     

    Good info, makes sense now.  I could call RefreshMain, but it resets my grid.  So the info I'm passing is wrong.  This file watch process won't work anyway, as I was trying to solve a problem.

     

    Thanks for the reply!

     

    Rudy

    Thursday, January 31, 2008 7:35 PM