|
how can i get usage cpu performance from wmi based on c# ?
many solution just write about sql script or the other.
|
|
|
|
|
when i use PerformanceCounter,
it can get a information cpu performance. but it just cpu own.
i.e, case of invoke progressbar, it can display cpu usage rate.
it just one thread. but i wanna get a cpu,network and memory usage rate.
so i make them in one thread. but always cpu usage rate 0% in my project.
i don't understand it.
following my code.
------------------------
PerformanceCounter p = new PerformanceCounter();
p.CategoryName = "Processor";
p.CounterName = "% Processor Time";
p.InstanceName = "_Total";
... progressbar invoke ...
float usage = p.NextValue();
progressBar1.Value = ((int)usage);
label1.Text = "CPU usage : " + ((int)usage).ToString() + "%";
.....
it can display useage rate...
i write this code in my project, but case on my project. it can't display performance.
|
|
|
|
|
Hello,
Have you tried this:
ManagementObject processor = new ManagementObject("Win32_PerfFormattedData_PerfOS_Processor.Name='_Total'");
processor.Get();
ulong value = (ulong)processor.Properties["PercentProcessorTime"].Value;
Valery.
|
|
|
|
|
I'm going to be writing a distributed app soon... a GUI will submit jobs to a server and the server will hand out jobs to up to 300 worker PCs.
Is there anything built in to .NET or some API available from Microsoft?
Seems like a lot of detail stuff (the 3 pieces communicating, updating status, etc) would have already been written?
I know there is Windows Azure / Cloud computing, but the boss doesn't want to use somebody elses cloud. Does Windows Azure let you build your own cloud? etc.
Basically looking for something like that.
Did a google search on some keywords, but found almost nothing.
|
|
|
|
|
Seems like a pretty standard operation except the worker PCs should request a job rather than have a job pushed to them.
Server creates a queue of jobs to be done, each pc grabs a job as it becomes free, fairly straght forward.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hmm... whats the advantage of pulling vs pushing? seems like just moving status management from the server piece to the client itself. How should worker status / heart beat be handled?
Anyways, I didn't think it was exceptionally difficult, I just thought to get it ROBUST and STABLE would take a lot of detail work and I'd rather just re-use something if possible .
|
|
|
|
|
Is there any reason the server needs to know the status of the worker beyond the pass/fail result of the process.
And yes I'll be interested to see if a framework comes out of the question.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
We need to know if a client is hung or crashed or had a hardware failure, etc. We aren't going to RDP or ping 300 machines .
|
|
|
|
|
my current project that is redesign about client framework architect.
i'm redesign to distribute process system from partial distribute system.
i'm allocate broker application server in framework and task base distribute.
it need some modify client system. but i will go almost least it.
current system base on c#.
if you have many client system, cloud is nice solution.
but cloud have many issue about system redesign.
sometimes you need modify your client software. it need too cost.
and you have plan system recovery about system shutdown.
|
|
|
|
|
that's a good question... i personally haven't seen a framework for this, but like you mentioned, i assume someone has already done this... post follow up info if you do find something...
|
|
|
|
|
Looked at BOINC[^]? Dunno if it's appropriate for you but it's free I'm pretty sure. And well tested - this is what runs SETI@home, I believe.
|
|
|
|
|
There is a native function wich takes arrays of pointers to data arrays e.g. char allocated with malloc.
void function(char** data, int nRows)
{
for (int i = 0; i < nRows; i++)
{
int nCols = _msize(data[i]);
for (j = 0; j < nCols; j++)
char val = data[i][j];
}
}
In managed code I have enumeration of byte[] arrays to pass to that function via PInvoke
unsafe void MyFunction(IEnumerable<byte[]> data)
{
var handles = data.Select(d => GCHandle.Alloc(d, GCHandleType.Pinned));
var ptrs = handles.Select(h => h.AddrOfPinnedObject());
IntPtr[] dataPtrs = ptrs.ToArray();
uint nRows = (uint)dataPtrs.Length;
function(dataPtrs, nRows);
handles.ToList().ForEach(h => h.Free());
}
[DllImport("function.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
static extern unsafe internal void function(IntPtr[] data, uint nRows);
However _msize call in native code leads to heap corruption. I remeber I used stackalloc with one dimensional array char* and concatenated byte[] arrays together.
But I need support for 'jagged array' with individual byte[] arrays of different sizes hence the need for array of pointers char**.
How to pin the byte[] arrays so that _msize correctly works as in stackalloc case?
Чесноков
|
|
|
|
|
Hello. Looking at the documentation for _msize function, it says that it returns the length of a memory block allocated by calloc, malloc or realloc so, since your byte[] arrays are allocated into the managed heap, I think it will not work unless you use Marshal.AllocHGlobal (and I am not sure if this would work) to allocate the memory and then copy data from managed heap to unmanaged heap and viceversa.
stackalloc could be used for one dimensional arrays becouse it is very similar to C _alloca function but, as far as I know, it is not possible in other cases, becouse stackalloc keyword can only be used when declaring and initializing a variable, I mean:
byte* pt = stackalloc byte[100];
byte* pt2;
pt2 = stackalloc byte[100];
|
|
|
|
|
Hello all,
My problem is I am having grey lines in a barcode after I resize it to a smaller size. Because of grays in the barcode, the reader cant read it.
The reader can read the original barcode before resizing it(it is all in black). I tried this but any improvement in my code or suggestion greatly appreciated;
Image bmpImage = Image.FromFile("C:\\barcode.bmp");
Bitmap bm = new Bitmap(bmpImage, new Size(192, 96));
Graphics gr = Graphics.FromImage(bm);
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.InterpolationMode = InterpolationMode.High;
Rectangle rectDestination = new Rectangle(0, 0, 192, 96);
ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders()[1];
EncoderParameters eParams = new EncoderParameters(1);
eParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
gr.DrawImage(bm, rectDestination, 0, 0, 192, 96, GraphicsUnit.Pixel);
PictureBox pbox = new PictureBox();
pbox.Image = bm;
gr.Dispose();
pbox.Image.Save("C:\\barcode_resized.bmp");
|
|
|
|
|
Hi,
IMO the best approach is to create a totally new barcode, i.e. scan the original at its original size (result is a string), then "print" that string to a new barcode at the size you want. There are a number of articles available on barcodes here on CodeProject.
You can try to use the existing one and rescale it, however then you must avoid all interpolation, therefore I suggest you use InterpolationMode.NearestNeighbor Even then the best results are to be expected when the resizing is by a simple fraction such as 1/2 or 2/3. Don't expect any success with extreme resizing, say 1/10.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, March 15, 2011 2:50 PM
|
|
|
|
|
Well I am resing it from 300 x 150 to 192 x 96. I think the barcodes becomes blurry because the resolution drops. I tried InterpolationMode.NearestNeighbor but didnt help. I will try your first approach now
|
|
|
|
|
I'm working on a C# WinForms app in VS2010. It seems that Crystal Reports is no longer included in VS. You now have to go
to SAP and download it. So I did, and now I'm getting:
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or
one of its dependencies. The system cannot find the file specified.":"log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304"
on this line:
private void InitializeComponent()
{
this.CRViewer = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
this.SuspendLayout();
this.CRViewer.ActiveViewIndex = -1;
this.CRViewer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.CRViewer.Cursor = System.Windows.Forms.Cursors.Default;
this.CRViewer.Dock = System.Windows.Forms.DockStyle.Fill;
this.CRViewer.Location = new System.Drawing.Point(0, 0);
this.CRViewer.Name = "CRViewer";
this.CRViewer.Size = new System.Drawing.Size(508, 379);
this.CRViewer.TabIndex = 0;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.CRViewer);
this.Name = "crlReportViewer";
this.Size = new System.Drawing.Size(508, 379);
this.ResumeLayout(false);
}
I have been Googling this for 2 days and found nothing really. It seems that this problem can be generated
for a variety of reasons. Anyone have any clue what's going on & what to do about it?
Everything makes sense in someone's mind
|
|
|
|
|
I had the same problem and here how I solved it.
CrystalReport for VS2010 is the 32bit version of CrystalReport, because VS2010 is a 32bit application. In fact, checking at
"C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\"
I found only a folder named win32_x86.
But, if your project target platform is "Any CPU" (default, usually) and you have a 64bit machine, when you run your application it needs the 64bit version of CrystalReport. As soon as I've realized that, I installed SAP Crystal Reports runtime engine for .NET Framework 4 (64-bit) fixing the problem.
I hope this is useful.
Bye
|
|
|
|
|
i want to run windows form program in more than one PC and the database to be in one PC and other PCs connect to it
DB (sql server)
>>>>>>>>
how can i control
*in setup of sql server
*or on connection string
*and what the requirements to make this is need to windows server or sql express
________________________________
tell me the steps and requirements please
|
|
|
|
|
You can create a WCF service that will interact with database on one machine and have various clients(Window/web) running on different machines. The client will interact through a URI of the service.
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
the program will run on local network
|
|
|
|
|
You can use SQL express as a server/service or as a local db.
Local db that is just the current PC can acess it:
"Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;"
Use it as server "Data Source=myServer(or the PC ususally .SqlExpress);Initial Catalog=myDataBase(the actual DB);User Id=myUsername;Password=myPassword;"
This is a sql authentification. Since it's on a local network if all the computers are on the same VLAN they should recognize it by the computer name.
You can insert the IP instead of the pc/computer name but make sure to create a static IP first for the pc that
acts as a server.
Anyway you will need to carefully analyze the requirements. That is how many users will be accesing the DB
at the same time, the complexity of the reports...
If that(the number of simultaneous users) is more than 20, I sugeest SQL full not express.
The express version has one big limitation. It can only use one CPU/core. So from a performance point of view
bad for multi user access.
As something to read about. I try to make something like the following (if possible) for all the apps for a enterprise.
Analize the complexity of the app mainly the complexity of the reports cause a simple insert or update is not that
big of a problem. And if the complexity of the reports is big(that depends on the server hardware too) I use the following config:
client => appserver => sqlserver.
Client = any desktop/laptop.
AppServer = a server that acts as an intermediar between the client and the DB server. Or in other words
a super PC that creates complex reports based on the raw data/info received from the DB server and not only.
The DB server well that is the SQLServer.
All the best,
Dan
modified on Tuesday, March 15, 2011 1:57 PM
|
|
|
|
|
thnx alot MDL=>Moshu
in sql server is need to enable tcp\ip or named pipes or something another in configuration
or when i setup sql express need to enable thing in setup
i try to use ip 127.0.0.1 and return exception
is there any port needed in the connection string
|
|
|
|
|
Hy,
0)Using 127.0.0.1 won't work when trying to access it form another computer. that is for localhost(s).
1) There is a setting when installing the SQL server. I haven't installed it in a while but I'm sure that there is
2) Normally no port needs to be changed.
Do you have SQL Management Express? If yes try to connect to the db using SQL auth not windows auth.
All the best,
Dan
|
|
|
|
|
Hello Everyone,
I am making use of podcast's very often. And in some versions of the podcast the quality is very low and have some scratching sounds in them. And I do not like to listen to them like that. So I started to play with different file formats.
I have a very old music match version that converts from MP3 to MP3 Pro VBR file format. In this format the scratches is hardly noticeable.
But I do not like Music Match on my system as it has plenty of bugs and known problems with vista onwards - or at least my version that i should have chucked 100 years ago - Don't get me wrong Music Match is great Not trying to make the product bad.
But anyhow... Does anyone know of any open source library that I can embed in a C# project to convert the files to the same file format?
I would really appreciate it
Thanks,
Chrispie
|
|
|
|