Join 136,800 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,328 people online right now. Registration is fast and FREE... Join Now!
I've got a thread, which runs regularly to update the recent posts on Twitter (Check the X-Twitter thread in Discuss Projects)
But the problem is, when you click the button to update a message, it freezes. I know why this is, I just don't know how to fix it.
It's freezing because it's trying to post to a webpage while reading another. Well, that would work, if my connection wasn't so crap. Sooo~ I need to pause the update thread and make the main thread priority when the button is clicked. After that, it can go back to listening.
I don't really have any code to post for this, since it's more of a how-to than "what's wrong."
I've read about ManualResetEvent and AutomaticResetEvent, but I'm not sure what to do with them.
NOTE: I'm trying to pause the update thread from the main thread.
You might want to look into Asynchronous threading. Using this type of implementation you can poll the thread to determine the completion status of the thread before moving on to the next thread.
Wow. I think that completely answered my question, and more. Thanks baavgai
If that isn't already a snippet, submit it~ I'll approve it right away. (Though it could do with a few comments)
One question though~ what's this "System.Linq" ? I saw it in another thread earlier. I had to take it out when I was compiling, it said it wasn't found?
If that isn't already a snippet, submit it~ I'll approve it right away. (Though it could do with a few comments)
Eww, comments are for wimps. I'll see what I can do.
QUOTE(gabehabe @ 2 Oct, 2008 - 05:22 PM)
One question though~ what's this "System.Linq" ?
New toy in VS 2008, LINQ, so they insist on forcing it in by default. It's basically a way to derive a resultset from a collection in a supposedly more intuitive syntax. I believe it's what happens with SQL people and LISP people get hammered and start messing with the language specs. I honestly didn't see anything it could do for me that I couldn't do just simply with more natural feeling methods. This site seemed to have a lot of good examples.
As for the JobQueue, it works wonders~ I posted a couple of test from X-Twitter while I was testing it. (I've created a JobQueue.cs file, and put you as the author~ When I come to the credits, I'll put you in.)