473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Child thread cannot access static field?

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!

Feb 26 '06 #1
2 2249
AdamM <no****@nospam.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 26 '06 #2
Ah, that's the issue!

Thanks very much for the info! I'll have to work around that one.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
AdamM <no****@nospam.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Feb 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Manisha | last post by:
Hi, I am creating a C++ dll which is used to process data passed to it through one of its exported functions. It should be able to process 160 simultaneous requests. For this reason, I have...
6
by: GG | last post by:
Is this public static method thread safe. //Receives a file name as a parameter //and returns the contents of that file as a string public static string FileToStr(string fileName) { FileStream...
8
by: GTi | last post by:
I have a UI Class with StatusBarPanels Then I have another Class that is a thread. I want this class thread to update the StatusBarPanels in the UI class. But I get the error: error CS0120: An...
1
by: Diffident | last post by:
Guys, I have been cracking my head over this concept in .NET framework. I have read many posts on this topic but not clear about this and hence I am posting it again. If you have designed...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
by: Warren Sirota | last post by:
Hi, I've got a method that I want to execute in a multithreaded environment (it's a specialized spider. I want to run a whole bunch of copies at low priority as a service). It works well running...
6
by: foolmelon | last post by:
If a childThread is in the middle of a catch block and handling an exception caught, the main thread calls childThread.Abort(). At that time a ThreadAbortException is thrown in the childThread. ...
1
by: Richard | last post by:
Greetings. I am total newbie to Javascript so what is written below is probably a bunch of cobblers!! Any assistance in correcting my code much appreciated. I wish the popped up child to pass...
12
bilibytes
by: bilibytes | last post by:
hi, i need some help here. how can i access a static property of a subclass. i have an abstract class which will be extended... each extending class will have a static property that will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.