Child thread cannot access static field?

  • Thread starter Thread starter AdamM
  • Start date Start date
A

AdamM

I have a "Lib" class with a public static string called Test.
Another application sets Test="testing123" and then spawns a new thread. Strangely, the new thread can see Lib.Test, but the contents of that static variable come back as null. The parent app can use Test fine.

The new thread can see the contents of any static variable initialized by Lib itself, and other applications can see Lib.Test's contents correctly, but my app's child thread always gets null back.

I checked references to Lib and all seems well.

There is something more complex happening that I don't understand. Any tips would be appreciated...

Thanks!
 
AdamM said:
I have a "Lib" class with a public static string called Test.
Another application sets Test="testing123" and then spawns a new
thread. Strangely, the new thread can see Lib.Test, but the contents
of that static variable come back as null. The parent app can use
Test fine.

If you genuinely mean a different *application* then that's the
problem. Static variables are effectively scoped by application domain
- things in a different app domain (let alone a different process)
won't see each others' values.
 
Ah, that's the issue!

Thanks very much for the info! I'll have to work around that one.
 

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

Back
Top