Using Multi threading

V

vishal

hi dear

i am working on .net(1.1) web service and due to delay in response i made it multi threaded

but when i passed a object in function which is called on a new thread, it is throwing ObjectNullReference exception...

because it is unable to get value from the property of that object....

but by looking in quickwatch the state of object where it is throwing that exception

all the private member of object are having there values but in value column of quickwatch window

it is showing "error : cannot obtain value" against each and every public member.

i am giving you the source code how i am doing multi threading...


public class Threading
{
Testing testing = new Testing(PassedObject obj);
ThreadStart threadStart=new ThreadStart(testing.PerFormSomeAction);
Thread thread=new Thread(threadStart);
thread.Start();
}


public class Testing
{
private PassedObject _obj;
public void testing(PassedObject obj_)
{
this._obj=obj_;
}
public void PerformSomeAction()
{
// code here
// it is showing error here while accessing some of the property of _obj.
// but by using quickwatch it is showing value of private member's and displaying "error:cannot obtain value" for public members..
}
}

please help in the matter..

a kind reply is awaited


reply to : (e-mail address removed)
(e-mail address removed)

regards
vishal
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

<vishal> wrote in message | hi dear
|
| i am working on .net(1.1) web service and due to delay in response i made
it multi threaded

Are you sure that the delay will be eliminated by it?
Did you check your code to where slow code is?

| but when i passed a object in function which is called on a new thread, it
is throwing ObjectNullReference exception...

| because it is unable to get value from the property of that object....

That is usually a sign that you are using an object before nitialize it;


| public class Threading
| {
| Testing testing = new Testing(PassedObject obj);

What is this? I assume this is not your running code as the above line will
no compile


The rest of your code seems fine. That is the pattern used to pass
parameters to threads.


A question though, is _obj or one of his properties the one that is null?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top