473,320 Members | 1,887 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,320 software developers and data experts.

Static constructor processing

Will object instantiation of an object not occur until the static
constructor has run? In other words, if I have logic in a static
constructor that takes, lets say 5 seconds. Will all other attempts to
create an object of that type be "blocked" for that 5 secs until the static
constructor processing has occurred?

Nov 16 '05 #1
3 1971
Kevin C <kc@noneya.com> wrote:
Will object instantiation of an object not occur until the static
constructor has run? In other words, if I have logic in a static
constructor that takes, lets say 5 seconds. Will all other attempts to
create an object of that type be "blocked" for that 5 secs until the static
constructor processing has occurred?


Yes, they will.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
> Will object instantiation of an object not occur until the static
constructor has run? In other words, if I have logic in a static
constructor that takes, lets say 5 seconds. Will all other attempts to
create an object of that type be "blocked" for that 5 secs until the static constructor processing has occurred?

If you explicitlx provide a static ctor the type is not marked with
beforefieldinit which means that it is guaranteed that the static ctor run
exactly at the moment before you access the first time a field of this class
or create an instance. You can also rely on that behaviour in a
multithreaded program.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 16 '05 #3
Perfect thanks!!

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Kevin C <kc@noneya.com> wrote:
Will object instantiation of an object not occur until the static
constructor has run? In other words, if I have logic in a static
constructor that takes, lets say 5 seconds. Will all other attempts to
create an object of that type be "blocked" for that 5 secs until the static constructor processing has occurred?


Yes, they will.

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

Nov 16 '05 #4

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

Similar topics

3
by: Amit | last post by:
is there anything like static constructors or destructors in C++ ? if yes, how to implement it? Thanks, Amit.
10
by: Grahamo | last post by:
Hi, I have a a routine that is frequently called. It simply iterates over a list of dates and does some sanity checking. The following pseudo code summarises it. void check() { const Date...
3
by: Kevin C | last post by:
Will object instantiation of an object not occur until the static constructor has run? In other words, if I have logic in a static constructor that takes, lets say 5 seconds. Will all other...
1
by: Ray Ackley | last post by:
I'm experiencing a threading problem that's really perplexing me. I have a multithreaded application that reads car ECU information that's sent over the serial port by the ECU and received by the...
5
by: | last post by:
Hi, How long do webservice objects live for? In particular, if i have static variables filled with data from a static constructor in a webservice, how long will that data persist? thxs
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
12
by: Hemanth | last post by:
Hi, I have a base class with a static constructor and some abstract methods. Derived classes implement these methods. From articles on the web, it appears that there is no guarentee that this...
10
by: John A Grandy | last post by:
Say I have Class1 which contains static Class2 var1 = new Class2(); Is Class2 constructor code only executed if var1 is referenced in the code-execution path ? Or is Class2 constructor code...
4
by: mnowosad | last post by:
As far I know, static variables are tied to AppDomain scopes. So, every time an executing code within an AppDomain references a class for the the first time since the AppDomain was created/loaded,...
4
by: BLUE | last post by:
VS .NET 2003 CF In this method I cannot catch exceptions thrown by Settings constructor (for example FileNotFoundException) but only an OutOfMemory exception due to Get returning void. Why??? ...
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...
0
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...
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: 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.