I'm writing a windows forms application for viewing forums.
I have a user, thread and post class. The user class contains an arraylist of threads (threads the user has created) and in turn the threads class contains an arraylist of posts (posts in the thread).
In order to get the threads and posts for a user I'm using code along the lines of
The problem I'm having is that when this code is executed, all of the getPosts methods seem to run concurrently (one for each thread object), seemingly each in it's own thread. This causes an issue as the getPosts method involves navigating to a web page and reading it. I'm finding that the next thread is calling the getPosts method before the previous one has finished. This is causing issues at runtime.
How can I ensure that the program runs only in a single thread so that one thread object completes it's getPosts method, before the next one starts.
(sorry for the confusion with threads and threading)
Thanks
I have a user, thread and post class. The user class contains an arraylist of threads (threads the user has created) and in turn the threads class contains an arraylist of posts (posts in the thread).
In order to get the threads and posts for a user I'm using code along the lines of
VB.NET:
for each t as thread in alThreads
t.getPosts
next
The problem I'm having is that when this code is executed, all of the getPosts methods seem to run concurrently (one for each thread object), seemingly each in it's own thread. This causes an issue as the getPosts method involves navigating to a web page and reading it. I'm finding that the next thread is calling the getPosts method before the previous one has finished. This is causing issues at runtime.
How can I ensure that the program runs only in a single thread so that one thread object completes it's getPosts method, before the next one starts.
(sorry for the confusion with threads and threading)
Thanks