Results 1 to 11 of 11

Thread: [2008] Using .NET async methods

Threaded View

  1. #1

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Exclamation [2008] Using .NET async methods

    I have noticed that the .NET framework contains extensive amounts of asynchronous methods (identified by the Begin and End keywords). They usually take an AsyncCallback (or other callbacks) and an Object as parameters. Unfortunately, given my limited experience with multithreading, I was unable to understand the MSDN documentation on the proper use of callbacks and am now left dead in the water with my current project. How do I use the callback objects?

    Can anyone please show me a proper way to fill an array of bytes by using multiple threads (or the ThreadPool) for a sub which takes two Integers as parameters? When I try to add arguments to a method after the AddressOf keyword, it tries to treat the method as an array, resulting in an error.

    The scenario is as follows:
    A byte array needs to be filled with data. The data is received from a server via the WebResponse stream. Since the server must be contacted several times, possibly with different URIs every time, the interaction must be concurrent. Then each response must be written at the appropriate position in the byte array. In the end, the byte array must be returned to the calling thread.

    I know that it is unusual to write to an array concurrently, but it's an application requirement. Unless someone proposes a better method to get the data concurrently and then write it in an array with the same effect, of course.
    Last edited by obi1kenobi; Dec 30th, 2008 at 02:53 PM.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

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