Hello,
Firstly your forum has solved many of my questions in the past, I have had to register to find the solution to this one.
The current application I am working on is multi-threaded and I am really getting confused with VB.NET's way of doing things (ex Java programmer).
Basically,
A schedule class runs every 60 seconds querying our database for new "Job's" to do. If it finds "Job's" it spawns a Job thread for each job and waits another 60 seconds.
A Job class fetches required "Report's" of the "Job" and spawns a "Report" thread for each of the "Reports". (Note: a report thread can take 1 sec to 20 sec to run)
My problem is, I have implemented a delegate sub in the "Job" class that the "Report" class threads use. Leading to my problem that when two "Job" threads are running the "Report" threads aren't talking back to the correct "Job" thread. The "Report" threads need to pass back the processed data to the "Job" thread for merging.
Are delegates the best way to handle communication between my threads. The examples I have seen the Delegate subs or functions have been in the same class. My problem is that I have had to make it Shared in the Job class so the Report class can see it without having to make an instance of the Job class.
(I would post code, but its a lot of code. Will post snippets soon once I can make it simpler to understand)
Summary:
Schedule (Polls database for Jobs)
Job (Handles the Job from the database)
Report (Handles the Report part of the Job)