By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Problem with FileSystemWatcher/Tray Notifier App

P: n/a
Hi,

I've been developing an application in VB.NET that uses the
FileSystemWatcher and a popup notification in order to tell me when files
have been downloaded.

The FileSystemWatcher code in my project is basically the same one thats
floating all over the VB.NET sites (by Jayesh Jain). The popup notification
(called TaskbarNotifier) is a class originally by John O'Byrne written in C#
and C++ but ported to VB.NET by Patrick Vanden Driessche. It was downloaded
from codeproject.com.

Both of these elements (FileSystemWatcher and TaskBarNotifier) work
perfectly on the own but I experienced problems when I tried incorporating
and combining them in my own project.

Basically, the FileSystemWatcher will detect files created, changed, deleted
etc and the TaskBarNotifier will display popups as it should. The problem
comes when I create a file (by means of downloading it or by just copying it
to the 'watched' folder directly). I've coded it so the TaskBarNotifier
should popup with name of the file created/downloaded then disappear after 3
seconds. It should, but doesn't. I can't understand why the same code will
not run when used under a different procedure.

I would of prefered to paste the code here in the hope people willing and
able to help can paste it directly into their own VB.NET environment but the
project contains bitmaps (as Embedded Resources) for the skins of the popups
and they need to be included when compiling/testing the app otherwise it
won't compile. So for this reason I've posted the project on my website for
download.

Homepage: http://www.geocities.com/toffee_paul/fun_d_mental.html
Direct Link: http://www.geocities.com/toffee_paul/vbnetproj.zip

When compiled and the form is displayed, click 'Test just the Popup' and the
popup will appear as it should. Now change the 'watch folder' to a valid
folder and copy a file to this folder. The app will detect the newly
created file (as proven in the 'content' textbox) but the popup will fail to
appear. Very strange problem.

Any help is very much appreciated,
Thanks
Paul
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Paul" <pr*****@mail.com> schrieb:
The FileSystemWatcher code in my project is basically the same one thats
floating all over the VB.NET sites (by Jayesh Jain). The popup
notification (called TaskbarNotifier) is a class originally by John
O'Byrne written in C# and C++ but ported to VB.NET by Patrick Vanden
Driessche. It was downloaded from codeproject.com.

Both of these elements (FileSystemWatcher and TaskBarNotifier) work
perfectly on the own but I experienced problems when I tried incorporating
and combining them in my own project.


Make sure that the 'FileSystemWatcher''s 'SynchronizingObject' is set to
your form. Otherwise your event handlers are executed on a thread of the
thread pool and thus invoking will be required to access Windows Forms
elements running in the application's main UI thread.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
Brilliant, thanks Herfried!

I added the following line to the Load event of my form....

WatchFolder.SynchronizingObject = Me

And all works perfectly now.
Thanks again.
Paul

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e8**************@TK2MSFTNGP11.phx.gbl...
"Paul" <pr*****@mail.com> schrieb:
The FileSystemWatcher code in my project is basically the same one thats
floating all over the VB.NET sites (by Jayesh Jain). The popup
notification (called TaskbarNotifier) is a class originally by John
O'Byrne written in C# and C++ but ported to VB.NET by Patrick Vanden
Driessche. It was downloaded from codeproject.com.

Both of these elements (FileSystemWatcher and TaskBarNotifier) work
perfectly on the own but I experienced problems when I tried
incorporating and combining them in my own project.


Make sure that the 'FileSystemWatcher''s 'SynchronizingObject' is set to
your form. Otherwise your event handlers are executed on a thread of the
thread pool and thus invoking will be required to access Windows Forms
elements running in the application's main UI thread.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.