Solved

Need help with ParameterizedThreadStart delegate

Posted on 2007-11-18
6
990 Views
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();
                    al.Add(initialISBNRetValue);
                    al.Add(isbnRetValue);
                    t.Start(al);

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?

0
Comment
Question by:rmmarsh
  • 3
  • 3
6 Comments
 
LVL 55

Accepted Solution

by:
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];

0
 

Author Comment

by:rmmarsh
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?
0
 
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.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

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

Expert Comment

by:Jaime Olivares
ID: 20308739
use Abort().
Have a look for this simple tutorial about .net threads:
http://www.codeproject.com/cs/threads/csharp.asp
0
 

Author Closing Comment

by:rmmarsh
ID: 31409822
Thanks again...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now