Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2005

Tip: Looking for answers? Try searching our database.

Problem with FileSystemWatcher/Tray Notifier App

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul - 02 Jan 2005 09:39 GMT
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
Herfried K. Wagner [MVP] - 02 Jan 2005 12:18 GMT
"Paul" <private@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
[quoted text clipped - 5 lines]
> 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.

Signature

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

Paul - 03 Jan 2005 10:02 GMT
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

> "Paul" <private@mail.com> schrieb:
>> The FileSystemWatcher code in my project is basically the same one thats
[quoted text clipped - 11 lines]
> thread pool and thus invoking will be required to access Windows Forms
> elements running in the application's main UI thread.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.