Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Need help with ParameterizedThreadStart delegate

Posted on 2007-11-18
Medium Priority
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 2000 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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

715 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