Need help with ParameterizedThreadStart delegate

Posted on 2007-11-18
Last Modified: 2012-08-14
I have defined two arrays that I need to pass to a thread:

            Service.isbnAndPrices[] initialISBNRetValue = new Service.isbnAndPrices[100];
            Service.isbnAndPrices[] isbnRetValue = new Service.isbnAndPrices[totalRecordCount];

I have defined the call to start the thread as:

                    ParameterizedThreadStart pts = new ParameterizedThreadStart(getISBNPricingData);
                    Thread t = new Thread(pts);
                    ArrayList al = new ArrayList();

and finally, the actual method that I want to run as a separate thread:

        private void getISBNPricingData(object data)
            Cursor.Current = Cursors.AppStarting;
            Service.isbnAndPrices[] initialRetValue = (ArrayList)data[0];
            Service.isbnAndPrices[] retValue = (ArrayList)data[1];

The problem is the last two lines above; I am getting an error stating: Cannot apply indexing with [] to an expression of type object.

How do I fix this?

Question by:rmmarsh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 55

Accepted Solution

Jaime Olivares earned 500 total points
ID: 20308645
try with:

private void getISBNPricingData(object data)
            Cursor.Current = Cursors.AppStarting;
            ArrayList array = (ArrayList)data;
            Service.isbnAndPrices[] initialRetValue = (Service.isbnAndPrices[])array[0];
            Service.isbnAndPrices[] retValue = (Service.isbnAndPrices[])array[1];


Author Comment

ID: 20308678
Unbelievable!  Thank you soooo much!  Sometimes I just can't figure it out...

One more question:  what is the proper way to stop this thread so I don't have memory leaks?
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20308699
Do you have any specific requirement with the thread stuff?
Usually you just have to return from your thread function.
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.


Author Comment

ID: 20308712
Well, that would work also... but I have a "stop" button to stop the process... do I just use "suspend"?
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20308739
use Abort().
Have a look for this simple tutorial about .net threads:

Author Closing Comment

ID: 31409822
Thanks again...

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question