|
superda wrote: at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
what's the target method of that invoke call? obviously the exception is thrown there.
|
|
|
|
|
HI,
I HAVE CREATED NEARLY 3 DELAGATES METHOD INSIDE THE THREAD FUCTION.HOW DO I FIND OUT WHICH DELEGATES THROWS THE ERROR.
Regards,
Nags
bgfhrtydgfdhfghhdf
|
|
|
|
|
if you run it in debug-mode, stack trace will tell you in which line of the Thread-Method the error occurred.
or you could set break-points in the methods where gdi is used.
|
|
|
|
|
superda wrote: HI,
I HAVE CREATED NEARLY 3 DELAGATES METHOD INSIDE THE THREAD FUCTION.HOW DO I FIND OUT WHICH DELEGATES THROWS THE ERROR.
Don't shout.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I'm looking for something like the old Windows API FlushEvents().
I have a form which creates a COM object like such:
COMServerObject foo = new COMServerObject;<br />
While my code waits for this statement to return, Windows makes my form window modal. If it takes a while for this statement to return - up to 20 seconds for .NET to give up and throw an exception - Windows queues up mouse clicks and keyboard events on my form, and then plays them back once the statement returns.
This is nasty, as the user hammers away at my unresponsive window, even trying to close it. So once the statement returns, my window can suddenly fly around the screen, resize, minimize, and even close.
I've tried disabling the Form while while I wait:
this.Text = "Hey, wait!";<br />
this.Enabled = false;<br />
COMServerObject foo = new COMServerObject;<br />
this.Enabled = true;<br />
this.Text = "Hey, thanks for waiting."
And this prevents clicks on my various buttons and menus. However, it does NOT prevent clicks on the window frame or title bar or close controls, so they still get queued up.
How can I prevent these from queuing? In the old Windows API, you could call FlushEvents when you got back from a modal state, which would remove all Windows events from it's message queue. I can't find anything analogous in the .Net framework. Anybody know the proper technique, here?
|
|
|
|
|
Inside your "wait" loop, you could put in a Application.DoEvents, This will allow your form to continue to run and respond to user clicks accordingly.
Just because we can; does not mean we should.
|
|
|
|
|
There is no "wait loop". You have misread the question.
The call to create the object
COMServerObject foo = new COMServerObject
is synchronous - control does not come back to my code for up to 20 seconds. During that time Windows holds my window unresponsive. During that time, Windows is queuing up events, which all get played back as soon as this one, singular statement returns.
What I want is to immediately flush the queued up events when control comes back to me, so they don't get replayed at all.
|
|
|
|
|
Hi
Can someone suggest me how to access cookies in a domain.
Reena.
|
|
|
|
|
Be more clear, please.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
StreamReader sr = File.OpenText(pth);
str = sr.ReadToEnd();
byte[] m_abyData = new byte[str.Length];
int iPos = (0 / 3);
int iLen = (str.Length < (str.Length - iPos)) ? str.Length : (str.Length - iPos);
for (int i = 0; i < iLen; i++)
{
m_abyData[i] = (byte)str[i];
sbVar.Append(string.Format("{0:X2}", m_abyData[i]));
}
this is my actual code.
but it takes very long time for large file.(large in size).
e.g 70,000 kb it takes very long time.
give me solution for fast conversion.
|
|
|
|
|
Don't double post. People have already answered on your other thread[^]. You should post follow-up messages to that thread, not start a new one.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Some ideas that might make your code work more efficiently.
piyush1230 wrote: str = sr.ReadToEnd();
So, you need to reserve a large block of memory to read the file. It is more efficient to read smaller chunks of the file, say a kilobyte or two, at a time.
piyush1230 wrote: m_abyData[i] = (byte)str[i];
You convert the string you have read form the file into a string, then convert it (badly) to binary again. Why not just read the file as a binary file in the first place? Then you won't have a double conversion. (i.e. .NET reads the file as binary then converts it to a string because that is what you asked for, then you convert it back to binary)
piyush1230 wrote: sbVar.Append(string.Format("{0:X2}", m_abyData[i]));
sbVar is not declared anywhere in the code you've provided so I'm guessing that it is a StringBuilder object. Do you need to build this in memory? Can it be written to a file as you go?
|
|
|
|
|
sbVar is StringBuilder.
I want solution for ( for loop ).
I want to eliminate for loop.
Plz. give me Instead of for loop any other function.
or give me code for using memory buffer ect. instead of array.
this code is for win ce mobile.
|
|
|
|
|
Hi,
two comments:
1.
a StringBuilder object acts like an array with some length (it's "Capacity").
When you append something and exceed the capacity, a new array is allocated and
all data is copied; this has a quadratic cost. It is better to allocate a
StringBuilder with sufficient initial capacity (twice the byte count of your file!).
I suggest you read up on StringBuilder documentation.
2.
I don't know what you intend to do with the entire hex stuff. Maybe you don't need
it all at once; if e.g. you want to write the data to another file, you can do the
read-convert-write process in chunks without ever needing a big array/string/StringBuilder
(and without wasting the memory).
|
|
|
|
|
|
Try reading up on how an ftp server works, the protocols, the standards, and then if you have a specific question about building an FTP server, post it up.
Just because we can; does not mean we should.
|
|
|
|
|
How can I get DateTime.now in this format: "Wed, 05 Apr 2006 21:12:00 GMT" ?
/\ |_ E X E GG
|
|
|
|
|
|
For instance, you can use:
string const MY_LONG_FORMAT = "MM/dd/yy HH:mm:ss:ffff"
string output = DateTime.Now(MY_LONG_FORMAT);
Note that the above format is NOT the one you want; you'll need to look at the link I provided in the earlier post to see how to build your format string.
modified on Friday, December 28, 2007 3:48:36 AM
|
|
|
|
|
string output = DateTime.Now.ToString("MM/dd/yy HH:mm:ss:ffff");
it will also work
Becoming Programmer...
|
|
|
|
|
Please only use ISO 8601 compliant formats.
|
|
|
|
|
|
hi
how to get motherboard and hard-disk serial number
in C# code ?
than'k alot for any help
|
|
|
|
|
|
There's an article on this site, I don't remember it, but a search should bring it up.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|