Results 1 to 3 of 3

Thread: multithreading or creating project instances

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    USA
    Posts
    257

    multithreading or creating project instances

    I have been trying to create good multithreading programs and it is not working well considering the use of global variables, local variables etc and thread safe controls. I have not found a good way of doing it since it seemed to be not as efficient as just running it on a single thread.
    The program accesses facebook and twitter api, parses etc. and I am wondering if I can just create new tasks and map the program project file and fire new instances of the project.
    Someone suggested this using the taskfactory in 2010 but I thought this was just the same as the threadpool. Any suggestions on this:
    create windows services and set them to run on task scheduler??
    -- Please rate me if I am helpful --

  2. #2
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: multithreading or creating project instances

    You can always have a thread fire off that accesses the facebook api and parses etc... Then use a delegate to update your GUI interface with what ever information you like.

    Right after the firing off of the facebook thread you can fire off the Twitter thread that accesses the twitter api and parses etc. Then use a delegate to update your GUI interface with what ever information you like.

    Or you can join the facebook thread and then fire off the twitter one afterward to prevent commingling .
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  3. #3
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: multithreading or creating project instances

    It's impossible to answer a question about a multithreaded approach without seeing code examples. I can assure you if it's taking you longer to use multiple threads to accomplish a task that can be done in parallel you are doing something wrong.

    In general for working with web APIs you would use the asynchronous versions of network calls and not worry about managing your own threads. For example, you'd usually use HttpWebRequest.GetResponse() to send a request to the Twitter API; to do so asynchronously you would use BeginGetResponse() instead. Of course, it's not so easy as you have to know a thing or two about .NET's Asynchronous Programming Model and how to marshal calls between threads properly. This is easiest to explain in the context of an example. Why not post a small example of some code that doesn't seem to work like it should and let us see if you're doing something wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width