#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    8
    Rep Power
    0

    Smile WaitForMultipleObjects is not waiting all the thread to complete their task


    Hello Everyone,

    Hi opening multiple thread at run time and finally called function.
    WaitForMultipleObjects(nooffiles,handle, TRUE, INFINITE);
    but its not working for me
    Code:
    for(i=0;i<n;i++)
    {
         handle[nooffiles] =  (HANDLE)_beginthreadex( NULL, 0, &createthreadtohandlefile, foldertemp, 0, NULL);
    }
    
    WaitForMultipleObjects(n,handle, TRUE, INFINITE);
    Please can anyone suggest me. Why this WaitForMultipleObjects is not working properly?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    This code:
    Code:
    for(i=0;i<n;i++)
    {
         handle[nooffiles] =  (HANDLE)_beginthreadex( NULL, 0, &createthreadtohandlefile, foldertemp, 0, NULL);
    }
    should be:
    Code:
    for(i=0;i<n;i++)
    {
         handle[i] =  (HANDLE)_beginthreadex( NULL, 0, &createthreadtohandlefile, foldertemp, 0, NULL);
    }
    otherwise you have a lot of invalid handles in your handle array when you hand it off to WaitForMultipleObjects()
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    8
    Rep Power
    0
    i did like this only
    Code:
    for(i=0;i<n;i++)
    {
         handle[i] =  (HANDLE)_beginthreadex( NULL, 0, &createthreadtohandlefile, foldertemp, 0, NULL);
    }

IMN logo majestic logo threadwatch logo seochat tools logo