|
Did you check the BackgoundWorker class? It does all the dirty work for you. There are a number of nice&simple articles here on CP.
|
|
|
|
|
Obviously, he hasn't checked anything. If he had, he wouldn't be here asking that question. He would be thrashing google to within an inch of its life looking for examples of using the BackgroundWorker class.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I like using events and event listeners for this purpose.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
i am not able to find the lotus mail to field??
Can ne1 plz help me??
|
|
|
|
|
Sorry Lotus disabled that for C#, try somewhere else.
|
|
|
|
|
Hi all,
I have a class
public class Abc
{
private UInt32 x;
private UInt32 y;
private Int32 z;
};
I need to get the size of the class.
Please help!
Thanks in Advance.
San
|
|
|
|
|
Why, what possible relevance is the size of the file. Once it is compiled it is part of an assembly and does not have a "size".
If you want the number of characters in the file open it in word or open it using a streamreader and read in tha lines,counting the characters, file size use io.fileinfo
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You cannot get unmanaged size of a class.
See this example :
Abc abc = new Abc();
int size = System.Runtime.InteropServices.Marshal.SizeOf(abc);
Console.WriteLine(size);
If Abc is a class, then you get an exception.
If you change Abc to a struct, then you get a size (12).
|
|
|
|
|
Yes I got an exception since Abc is a class.
So how is to calculate the size?
|
|
|
|
|
Using some memory profiling tools. BTW, could you tell why you are worried with the size?
|
|
|
|
|
stancrm wrote: You cannot get unmanaged size of a class.
You can if you specify the class' layout (explicit or sequential).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi
you can use the Marshal.SizeOf(typeof(MyClass)) method in the
System.Runtime.InteropServices namespace.
regards
|
|
|
|
|
When I given as per your suggestion I got an exception as follows.
An unhandled exception of type 'System.ArgumentException' occurred in exe
Additional information: Type 'class' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
|
|
|
|
|
San wrote: no meaningful size or offset can be computed.
I think you now have the answer to your question.
|
|
|
|
|
San wrote: I need to get the size of the class.
Why?
IIRC, a class like that would use 20 bytes on a 32 bit system and 28 bytes on a 64 bit system. Each object consists of two pointers plus the instance data.
As you see, the size differs depending on the version of the CLR (which determines the memory layout). Also, you have a pretty simple example. If you have members of different data types, they may be aligned on an even word boundary which may add to the size, and they might get rearranged to make best use of memory when aligned. So, it might not be possible to predict exactly how large the object can be.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Monday, September 8, 2008 9:31 AM
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
public class Abc
{
private UInt32 x;
private UInt32 y;
private Int32 z;
};
int size = Marshal.SizeOf(typeof(Abc));
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
HI!! i've a problem: i have a listview, and i wont that when i click in a line, the program should show me the printpreview of that object. in the listview there are only the file path to the file(ex: C:\filename.doc) ...how can i do??
sorry for my english, i'm not very good...(i'm italian)
thank you!!
|
|
|
|
|
If I understand correctly, your listview contains a list of documents. If they are all word documents, you will possibly need to use the Office Interop and open up the documents using Word (don't use Process.Start to open the docs). Then, your application will call the Print Preview command.
|
|
|
|
|
how can i use the Office Interop??
for exemple:
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
//what can I write here?
}
|
|
|
|
|
You'd have to import the Word automation library through the COM portion of the Add References dialog. Once that's in place, you've got the Word Interop library. If you have a google for word interop, there should be plenty of examples of the exact code you'll need for your application.
|
|
|
|
|
|
You're welcome. Glad to help.
|
|
|
|
|
Hi all,
I have a very long form, so I need to use vertical scrollbar to see all parts of it.
I need to capture the image of WHOLE form, but using standard CopyFromScreen method only captures the displayed area, while the scrolled part isn't captured.
Can anyone help me how to solve it?
Thanks a lot.
-mia-
|
|
|
|
|
try to make a panel and put the ControlCollection "Controls" from the Form into the panel and set the Panel "AutoSize" and make from the Panel the Screenshot...
i don't know if it works, but that would be my first try to solve this.
|
|
|
|
|
hey ppl! Any freeware source code for bmp to jpeg image converter??. Thx ahead
|
|
|
|