Results 1 to 2 of 2

Thread: [RESOLVED] [VS2005] Threading

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    midewest u.s.
    Posts
    275

    Resolved [RESOLVED] [VS2005] Threading

    I have a program that is running multiple threads at the same time. The maximum amount of threads is a user-changeable option. I was doing some testing on this and after a certain amount of threads have been called, I get a System.OutOfMemoryException.

    I have a program I created in Visual Studio 2003 that never had this problem, it did pretty much what this application is doing, and it doesn't give me that error with even more threads being called than my current application.

    I know they have changed a few of the threading things with the new 2.0 Framework, I was wondering if they made a max limit of sorts also?

    I guess, my questions are...
    1) What is the correct way to start a thread?
    2) Do I need to close/dispose the thread in some way? (An example of this would be helpful if this is the case).

    Here is the code I am using, and where the error occurs.

    lbox is an arraylist of values that need calculated.
    threadParamClass is a class I made to pass parameters via thread.
    The thread can access the parameters passed this way.
    PHP Code:
                 for (int x 0<= thecountx++)
                 {
                     
    Application.DoEvents();
     
                     
    gu null;
                     
    mythread null;
                     
    gu = new threadParamClass(f1thisx,lbox[0].ToString());
                     
    mythread = new Thread(new ThreadStart(gu.Calculate));
                     
    mythread.IsBackground true;
     
                     
    mythread.Start(); //out of memory here
                     
    cint++;
                     
    f1.textStat.Text "\\" thecount;
                     
    lbox.RemoveAt(0);
                     if (
    cint == 100)
                     {
                         
    manResetEvt.Reset();
                         
    manResetEvt.WaitOne(500000false);
                     }
                 } 
    Last edited by Tool; Dec 21st, 2006 at 04:04 AM. Reason: Resolved (Thanks wild_bill)

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