Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB.NET

File watcher in a module will not call method in a form. When the module code is moved to the form it all works well.

What I have tried:

I can not find syntax to do this. Is it even possible?
Posted
Updated 4-Dec-20 0:03am
Comments
Jo_vb.net 3-Dec-20 19:37pm    
Is the method in a form private or friend?
How do you call it?
Sandeep Mewara 4-Dec-20 0:07am    
Does this help: https://www.codeproject.com/Articles/3192/Watching-Folder-Activity-in-VB-NET

Once activity identified, call a method needed.
steve2015 4-Dec-20 9:01am    
Already saw this but thank you anyway. Solution #1 seems reasonable.

1 solution

Quote:
File watcher in a module will not call method in a form.
If the method in the form is not Public then it cannot be called from outside the context of the form.
Quote:
When the module code is moved to the form it all works well.
Because the file watcher and the form method are now encapsulated in the same context or scope - i.e. the form.

Beware! Just changing the method to Public is not necessarily the right solution. Should that method be on the Form or in a module - it sounds to me as if it should not be on the UI Component and should probably be on a separate thread.

However, start with the link from @Sadeep-Mewara - reproduced here as a clickable link Watching Folder Activity in VB.NET[^]
And if you want to it with Threads start here BackgroundWorker Class Sample for Beginners[^] - it's in C# but read the theory (and there are plenty of C# to VB.NET converters on-line)
 
Share this answer
 
Comments
steve2015 4-Dec-20 9:06am    
Great input thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900