473,324 Members | 2,178 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,324 software developers and data experts.

notification when a thread is created

Hello

I was wondering if there is a method that my class (or my assembly) can get
notified when a thread is created, in the same manner like DLL_THREAD_ATTACH
event in DllMain in Win32 unmanaged dlls?

The reason I want to do this, is that I have thread static fields that I
want to be initialized when the new thread starts.
Here is my current work around for this problem

[ThreadStatic]
private static MyClass myField;

public static MyClass MyProperty
{
get
{
if(myField == null)
{
// Initialize my object
}
return myField;
}
}

This works fine, but is not efficient. I access myField through MyProperty
to make sure the MyField is properly initialized. From the code you see that
every time the property get is called the if statement is executed to check
that myField has been initialized. I want to eliminated this check and
execute it only once instead of executing everytime.

Best regards
Sherif
Nov 15 '05 #1
0 949

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

Similar topics

1
by: Paul F. Williams | last post by:
Is there a way to determine when the system has performed a garbage collection? I would like to be able to write a console message when the CLR performs a GC. Knowing when a GC happens might help...
0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
3
by: cnu | last post by:
Hi, I am starting a new threading to do some process. I want to get notified when the thread does it's job and exits. After receiving the notification, I want to refresh the form. I am...
3
by: Will | last post by:
I have a Manager thread that launches a variable number of Worker threads. When each Worker thread finishes, I want it to notify the Manager thread that it's done so that the Manager thread can...
3
by: Kiran | last post by:
Hi, Was wondering if its possible to have a event notification in Thread when the thread is about to start and the thread has just finished doing its work and about to terminate. If its not...
1
by: Fred | last post by:
Hello, I've a question about implementing a group policy notification in c#. I've read the MSDN about this and they have a sample in C++....
2
by: SB | last post by:
Can someone please tell me Microsoft .NET's position on this WS-Notification specification that includes the pub/sub model? Is there something in the pipeline or already available as part of the...
2
by: Tim | last post by:
The are 2 threads - main thread and worker thread. The main thread creates the worker thread and then the worker thread runs in an infinite while loop till it is asked to exit by setting an event....
2
by: Jurjen de Groot | last post by:
I will be developping a planning application for wich it's necessary for multiple users to view and edit the same data, all changes made by one user, must be visible to the other user's more or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.