CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Posts
    24

    Best way to have multiple copies of class report to central location.

    Hi folks. I'm setting out on a small project and would appreciate suggestions how to achieve the one bit I'm not sure how to achieve. Well, achieve nicely!

    A routine on a form (for the sake of argument) will create multiple class objects, each on a different thread, each copy of the class needs to report progress back to the form that created them, raising events would be perfect but their timing isn't very reliable, I need something more stable. I also need something very flexible as I wont know how many classes will be running at any one time.

    Any ideas gratefully received.

    Cheers.

  2. #2
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    Re: Best way to have multiple copies of class report to central location.

    I believe each of the objects created will have access to all of the objects on/in the form. What timing issues are you running into?

    Maybe define some sort of array in the main form along with a counter. That way each thread's object can put data into the array, with some semblence of order, and a routine in the form can read through the array using it's own timing and not rely on events firing randomly.

    I would use an array of type whatever with an integer for the array position. Each object would, first thing, increment the position integer, then place the data in the array. If you increment the position first then you should not run into two objects using the same position.

  3. #3
    Join Date
    Dec 2012
    Posts
    24

    Re: Best way to have multiple copies of class report to central location.

    A global array that the main form can monitor? I have to admit, of all the ways I had thought of doing this, this wasn't one, but I do like it. This would allow a b.w. on the form to monitor each element of the array if required, and timing is completely my choice.

    I wonder if a datatable would be more efficient, creating an accessible row for each object. I will have to do some playing.

    Many thanks for the suggestion, very much appreciated.

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

Featured