|
|
Hello everyone,
For the following code, it is correct to say that,
1. obj1 will be instialized when .NET Runtime loads class Foo and before any instance is created?
2. obj2 will be created each time we create an instance of Foo, and obj2 will be called before constructor?
My question is whether my understanding (1) and (2) are correct?
class Foo
{
static private object obj1 = new object();
private object obj2 = new object();
public Foo()
{
}
}
thanks in advance,
George
|
|
|
|
|
Yeah, I believe so. You can write your own classes in place of the objects, and check it for yourself.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Cool, Christian!
Question answered.
regards,
George
|
|
|
|
|
George_George wrote: 1. obj1 will be instialized when .NET Runtime loads class Foo and before any instance is created?
No. The obj1 member will be initialised before any member of the Foo class is used, but not necessarily when the assembly is loaded.
George_George wrote: 2. obj2 will be created each time we create an instance of Foo, and obj2 will be called before constructor?
Yes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa,
Question answered.
regards,
George
|
|
|
|
|
hey guys
i need to hide or disable one of the pages in my tab control, but i cant find visible or enabled properties?
how else can i do it?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
From MSDN:
Additionally, the Hide method of the TabPage will not hide the tab. To hide the tab, you must remove the TabPage control from the TabControl..::.TabPages collection.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
thanx... but how will i put it back if its removed from the tabcontrol?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
My thoughts too, could you perhaps store the removed object locally somehow?
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
i think i could... everything being objects and all that.
thanx man, ill see how it works
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Hello everyone,
For Windows Service, for example class Service1 is the main class of my service application, which derives from ServiceBase. I am wondering whether it is possible that two concurrent access to the following 3 cases?
1. the constructor of Service1;
2. OnStart method of Service1;
3. OnStop method of Service.
If yes, I need some synchronizaton control in them. If yes, in what situation the three methods will be called concurrently? We are able to start/stop the same service with different instances (processes) at the same time?
thanks in advance,
George
|
|
|
|
|
I'm not really an expert here, but I think that since Windows Services are all handled in a unique central place, there is no need to worry about the constructor/OnStart/OnStop methods. However, you have to worry about access to other resources your service might use during normal operations.
|
|
|
|
|
Thanks Dario,
Is it possible that two different instances (processes) for the same Windows service will be started and run at the same time?
regards,
George
|
|
|
|
|
George_George wrote: Is it possible that two different instances (processes) for the same Windows service will be started and run at the same time?
No, unless you create two different services that point to the same executable.
Anyway, a service can be started only once, even using command-line tools or WMI.
On the other hand, two processes do not implicitly share memory, so you would not have concurrency problems even in the case a service was started twice, except for file access I guess (remember that all the Windows API are reentrant).
|
|
|
|
|
Good answer, thanks Dario!
So, I think the conclusion is there is no need to consider concurrent issue here.
regards,
George
|
|
|
|
|
George_George wrote: So, I think the conclusion is there is no need to consider concurrent issue here.
Exactly.
|
|
|
|
|
Cool, Dario!
Question answered.
regards,
George
|
|
|
|
|
Hello Friends,
I need to import a
MSAccess Database to SQL server 2005 using C# code.
My question will be is it possible to do so?--I googled and am yet to find a satisfactory answer.So i thought i will post the question.
Also is it possible to import a txt file to MSAccess?
If yes can you guys give me any links please.
Thanking You all
|
|
|
|
|
TXT to Acess: google search for "Access import txt"
Access to SQL Server: google search for "sql server database import wizard"
If you only need to import the access database once, there's no reason to write a program to do it. If you need to import the database on a regular basis, then all you need to do is run the import wizard once, then when the wizard prompts you to "Save SSIS" package, save it as a local file. Then you can simply setup a scheduled job to run dtexec and import the database. If you need more control than that look at the SQL Data Compare tool from RedGate software www.red-gate.com[^].
Mark's blog: developMENTALmadness.blogspot.com
Funniest variable name:
lLongDong - spotted in legacy code, was used to determine how long a beep should be. - Dave Bacher
|
|
|
|
|
Thank you Mark,I will check this.
|
|
|
|
|
Hello
Can someone help me for the below problem,
I am working on a task of accessing VB6 Application's Method in c#.Net.
I dont know how to access and use methods of VB6 in asp.net.
Thanks in advance
sri
|
|
|
|
|
I guess you can add a reference as COM component. But this is not recommended. You can copy the code from VB6.0 and put it in a VB.NET project, compile and use that assembly, which will be managed code.
|
|
|
|
|
Thanks for your immediate reply.
Is there any chance to use reflection to meet my requirement?
if so, Can anyone please tell me how?
Thanks in Advance
sri
|
|
|
|
|
I think you will find you can get to some of them through the various Microsoft.VisualBasic namespaces.
|
|
|
|