473,324 Members | 2,268 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.

Simple Question about WMI in C#

Hi,

I just want to write a small program to do some job on the remote system
with WMI, and my question is how can I deal with the WMI connection? To
connect the remote host once we need or just keep the connection alive?

I think maybe I can use a singleton pattern here, but I'm not sure what
the singleton should return, a ConnectionOptions or a ManagementScope?
Oct 2 '07 #1
3 1422
David,

I don't see what having a singleton here does for you. Perhaps if you
wanted to keep an open/persistant connection, then I can understand. In
that case, I would probably go with a ManagementScope instance. If you
return a ConnectionOptions instance, you will probably keep creating the
ManagementScope instance for your operations over and over again, and that's
extra code you don't have to write.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"David zha0" <zh*****@163.comwrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
Hi,

I just want to write a small program to do some job on the remote
system
with WMI, and my question is how can I deal with the WMI connection? To
connect the remote host once we need or just keep the connection alive?

I think maybe I can use a singleton pattern here, but I'm not sure what
the singleton should return, a ConnectionOptions or a ManagementScope?


Oct 2 '07 #2
Nicholas:

Thanks a lot for your reply, I meant to persist the connection during almost
the
whole lifetime of the program and, the ConnectionOptions won't be changed.

I think it is clear that I should keep an ManagementScope object...
Sorry for the stupid question :)

Thanks again.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comдÈëÏûÏ¢
news:#E**************@TK2MSFTNGP03.phx.gbl...
David,

I don't see what having a singleton here does for you. Perhaps if you
wanted to keep an open/persistant connection, then I can understand. In
that case, I would probably go with a ManagementScope instance. If you
return a ConnectionOptions instance, you will probably keep creating the
ManagementScope instance for your operations over and over again, and
that's extra code you don't have to write.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"David zha0" <zh*****@163.comwrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
>Hi,

I just want to write a small program to do some job on the remote
system
with WMI, and my question is how can I deal with the WMI connection? To
connect the remote host once we need or just keep the connection alive?

I think maybe I can use a singleton pattern here, but I'm not sure
what
the singleton should return, a ConnectionOptions or a ManagementScope?


Oct 4 '07 #3
Nicholas:

Thanks a lot for your reply, I meant to persist the connection during almost
the
whole lifetime of the program and, the ConnectionOptions won't be changed.

I think it is clear that I should keep an ManagementScope object...
Sorry for the stupid question :)

Thanks again.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comдÈëÏûÏ¢
news:#E**************@TK2MSFTNGP03.phx.gbl...
David,

I don't see what having a singleton here does for you. Perhaps if you
wanted to keep an open/persistant connection, then I can understand. In
that case, I would probably go with a ManagementScope instance. If you
return a ConnectionOptions instance, you will probably keep creating the
ManagementScope instance for your operations over and over again, and
that's extra code you don't have to write.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"David zha0" <zh*****@163.comwrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
>Hi,

I just want to write a small program to do some job on the remote
system
with WMI, and my question is how can I deal with the WMI connection? To
connect the remote host once we need or just keep the connection alive?

I think maybe I can use a singleton pattern here, but I'm not sure
what
the singleton should return, a ConnectionOptions or a ManagementScope?


Oct 6 '07 #4

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

Similar topics

11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
13
by: Michael B Allen | last post by:
Hi, I've tried to write the *simplest* memory allocator possible. I think it would be useful in many cases such as allocating memory on stack as a poor man's garbage collection perhaps. I was...
8
by: Beam_Us_Up_Scotty | last post by:
Hello all, I am trying to write a "simple" animation using C#, and I've tried many things but nothing seems to work for me without leaking memory. Here's a very simple piece of code that uses a...
2
by: Abel Chan | last post by:
Hi there, I just got an assignment to work on server maintenance. It is a weekly task and we have about 7 production servers running Win2K server. The tasks include but not limited to 1)...
7
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request...
10
by: serge calderara | last post by:
Dear all, I need to build a web application which will contains articles (long or short) I was wondering on what is the correct way to retrive those article on web page. In orther words, when...
10
by: Andrew | last post by:
Sorry about this but I'm new to ADO.NET (finally coming from simple ADO, bless it) and I'm trying to create a simple three tier program. Ie, User interface Layer / Business object layer / Database...
14
by: Giancarlo Berenz | last post by:
Hi: Recently i write this code: class Simple { private: int value; public: int GiveMeARandom(void);
1
by: =?ISO-8859-1?Q?Tor_Erik_S=F8nvisen?= | last post by:
Hi, A while ago I asked a question on the list about a simple eval function, capable of eval'ing simple python constructs (tuples, dicts, lists, strings, numbers etc) in a secure manner:...
17
by: Chris M. Thomasson | last post by:
I use the following technique in all of my C++ projects; here is the example code with error checking omitted for brevity: _________________________________________________________________ /*...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: 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: 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: 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.