|
Hi!
Has anyone an idea how i can get the cpu temperature with c#? I am going to develop a kind of hardware monitor.
Thx.
--== BINARY VICTORY ==--
|
|
|
|
|
There is a Win32_TemperatureProbe class in the WMI hierarchy that looks interesting, you can get to it via the System.Management namespace. I have never played with tracking down the CPU temp, so I could be off the mark here.
Regards
|
|
|
|
|
Scenario:
I have an object that has 2 overloads of a constructor. For some reason, overload1 in turn calls overload2.
i.e. I want to defer object creation until overload2 is eventually called.
I'm not sure of the syntax, as constructors don't seem to be treated as normal functions.
Can someone provide me with code for this?
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
class Foo
{
int value;
public Foo()
: this(0)
{
}
public Foo(int i)
{
value = i;
}
}
|
|
|
|
|
Thanks, Neil. I'll pass this on to my team.
Is this a good practice (constructor calling constructor)?
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
It’s more personal preference issue, although I don’t see how it could be a bad practice and in this case it is an integral part of the language. Code reuse (outside of cut and paste) is never a bad practice in my opinion.
Regards
|
|
|
|
|
Is there no additional overhead, in terms of MSIL code, to pull this off?
What about the alternative of creating an additional function that had the "shared" code that both constructors could use?
In your opinion, wouldn't this produce cleaner code?
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
Again, its personal preference. In overhead terms, there really is nothing to pull off; the initial constructor does generate a call to the target constructor. If you were going to supply a common private initialization member, it may accomplish the same thing with or without parameter passing. If your initialization member is parameterized, I would venture a guess that it carries the same amount of overhead.
Regards
|
|
|
|
|
In terms of cleaner code, if the class carries a significant amount of initialization that is common across all constructors, yes a shared initialization member can be cleaner.
I have also seen cases where these initialization members also become a reset mechanism for the class. Not that this is a bad thing, but in large projects and/or as time goes on and maintenance coding kicks in, it may be easier for a member of your team to forget what the primary purpose of the member was and start calling virtual members within it, which is a bad thing.
My two cents.
Regards
|
|
|
|
|
When I owner-draw my ListBox with this code:
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
ListBox listBox = (ListBox)sender;
bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false;
string displayText = listBox.Items[e.Index].ToString();
if(displayText.IndexOf("Sökresultat:") != -1)
{
if(selected == true)
{
e.Graphics.DrawString(displayText, new Font(this.Font, FontStyle.Bold), Brushes.White, e.Bounds);
}
else
{
e.Graphics.DrawString(displayText, new Font(this.Font, FontStyle.Bold), Brushes.Black, e.Bounds);
}
}
else
{
if(selected == true)
{
e.Graphics.DrawString(displayText, this.Font, Brushes.White, e.Bounds);
}
else
{
e.Graphics.DrawString(displayText, this.Font, Brushes.Black, e.Bounds);
}
}
}
When I add an item with a button the first item in the LisyBox will not be painted, when I click on it, it appears!"#?=`?=
What is wrong!!
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
Hi Friends
I wrote a C# ADO.NET Application and deployed it in a another Machine,
I installed the .Net Framework and ado 2.7,C# client app is working but the Ado is not working. Error says it can't find the ADODB.DLL Assembly.
How to setup the ADO.Net?
Thanks
Gaurika..
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Maybe you did it in the wrong order!
Install MDAC 2.7 first.
Then install the .NET redistributable.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Dear Nish.
I did it , but still it's not working , any idea ?
Thanks.
Gaurika.
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Gaurika,
Are you deploying your app manually or with a 3rd party P&D type product?
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
Dear Simon
I am deploying it manually , I installed the frame work and ado from the .Net Installatoin cd's
Gaurika.
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
I declare a export class in dll project in vc6 project.
How can i import it into c#?
I know we can use DllImport to make use of dll such as win32 api.
But have no idea of importing a class.
Any suggestion?
|
|
|
|
|
I don’t believe you can Interop with a class defined this way directly. You will either have to COM’ify the class, or build a managed wrapper around it in MC++, or rebuild it under VS.NET as a managed class.
Regards
|
|
|
|
|
I wrote a class library and named its namesapce "Mazdak.WebModule.Module1" and there is a class in it with "DBObject".Now in ANOTHER project I want to write another class and inherit it from my first class and name it "User" class.Now how can I import my first namespace and declare second class?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
In your second project add a reference to the first (if they are in the same project use the Project's tab, else reference the dll created in the first project).
Now in your second project extend it like you would any other class, ie
using Mazdak.WebModule.Module1;<br />
public class User : DBObject .
Good Luck,
James
Simplicity Rules!
|
|
|
|
|
Thank you James.It was very simple.I don't know why I forgot it.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
How to set bold style on a specific item?
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
well I found an example here:
http://samples.gotdotnet.com/quickstart/howto/doc/WinForms/WinFormsOwnerDrawListBox.aspx
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
Thanks good. Next time maybe you should mention that it is a List Box item you were trying to set
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
But I have problems with the code!
I don't know how to get the text from the item to be drawn in the dra item method!!
Can you help me!?
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
Rickard Andersson wrote:
don't know how to get the text from the item to be drawn in the dra item method!!
If it is an owner drawn listbox, you could just access the Item array for the item you are drawing.
Items[e.Index].ToString()
Where 'e.Index' is the DrawItemEventArgs item passed into the DrawItem.
Rocky Moore
|
|
|
|