PageAsyncTask Task

Sep 20 2011 9:15 AM
Hi,

I am trying to process files asynchronously as shown below:

 for (int i = 0; i < FileCount; i++)
 {
               
 FilePath = ViewState["SubFileName"].ToString() + (i + 1).ToString()  + ".sdf";
                              
        GetTask();
              
 }

void GetTask()
    {

        PageAsyncTask Task = new PageAsyncTask(new  BeginEventHandler(this.OnBeginFunct), new EndEventHandler(this.OnEndFunct), new EndEventHandler(this.TimeoutHandler), true, true);
            Page.RegisterAsyncTask(Task);
    }

    IAsyncResult OnBeginFunct(object sender, EventArgs e, AsyncCallback cb, object state)
    {
  AsyncTaskDelegate _runnerDelegateChem = null;
         _runnerDelegateChem = new AsyncTaskDelegate(FuncProcessFile);
               return result; 
    }

    void OnEndFunct(IAsyncResult ar)
    {
       
 //code to release all object and temp files
    }

Void FuncProcessFile()
{
 //code to process file
}


In the above code 'n' number of task are created for 'n' number of files(see for loop). But inside FuncProcessFile function always last file is processed. Please let me know how to associate FilePath varible with each task.

Thanks