|
Yes. It will be returned immediately.
|
|
|
|
|
Thanks N a v a n e e t h,
Question answered.
regards,
George
|
|
|
|
|
It's recommended that you call EndInvoke for every BeginInvoke called, regardless of whether you wait for completion. The MSDN page (http://msdn2.microsoft.com/en-us/library/2e08f6yc.aspx[^]) clearly says "Always call EndInvoke to complete your asynchronous call.".
1. Any exceptions that occurred in the asynchronous method will be thrown when you call EndInvoke, so if you don't call it, you'll miss those.
2. If the async method has any return values or out/ref parameters, then you'll need to obviously call EndInvoke to get them.
|
|
|
|
|
Good point, Senthil!
Two more comments,
1.
From the link you referred, I can not find words like "Always call EndInvoke to complete your asynchronous call", and it is appreciated if you could point out.
2.
S. Senthil Kumar wrote: 1. Any exceptions that occurred in the asynchronous method will be thrown when you call EndInvoke, so if you don't call it, you'll miss those.
I think you mean some code only calls WaitHandle without calling EndInvoke (WaitHandle is singnalled when asynchronous call completes, and you can have choice to ignore return value by without calling EndInvoke)?
If yes, I think the asynchronous method should be executed in another CLR thread, other than the current thread. Right?
And if any exception occurs in the CLR thread, could be caught in the current thread? I doubt it. Since I think the C# exception handling approach does not allow us to have cross-threads exception handling -- means exception occurs in one thread, and we can catch it in another thread? Any comments?
regards,
George
|
|
|
|
|
George_George wrote: From the link you referred, I can not find words like
Really? Did you try searching for the text? It's there in a small rectangular area titled "Important note".
George_George wrote: If yes, I think the asynchronous method should be executed in another CLR thread, other than the current thread. Right?
Um, but isn't that the very definition of an asynchronous method?
George_George wrote: And if any exception occurs in the CLR thread, could be caught in the current thread? I doubt it. Since I think the C# exception handling approach does not allow us to have cross-threads exception handling -- means exception occurs in one thread, and we can catch it in another thread? Any comments?
Any exceptions that occurred in the asynchronous method will be caught by the .NET framework and will be rethrown in the thread that calls EndInvoke. So yes, the framework does have the ability to handle exceptions across threads.
|
|
|
|
|
Cool, Senthil!
S. Senthil Kumar wrote: Any exceptions that occurred in the asynchronous method will be caught by the .NET framework and will be rethrown in the thread that calls EndInvoke. So yes, the framework does have the ability to handle exceptions across threads.
I think .Net framework does something special here in asynchronous method call. In normal case of multi-threaded programming in C#, the exception thrown from one thread can not be caught from another thread, right?
regards,
George
|
|
|
|
|
George_George wrote: In normal case of multi-threaded programming in C#, the exception thrown from one thread can not be caught from another thread, right?
Yes, because each thread has its own stack and exceptions cannot be propagated across stacks.
|
|
|
|
|
Thanks Senthil,
Your answer is clear.
regards,
George
|
|
|
|
|
hi all
i recently develop a project about E-seal(with office2007 word document), now i get the word file hash value(digest), and i need to put it back to the document, but i donot know which position of document is perfect. it is about the office program, so i use VSTO.
can anybody give prompt in detail
appreciate for any reply
|
|
|
|
|
Hi,
I am developing application in asp.net 2.0 using C#. My back end is sql server 2005. I also use microsoft enterprise library 2006.
My problem is:
First i pass three parameters to stored procedure from the application. After i increase one more parameter in both application as well as stored procedure, the application gives an error that parameter does not match with the stored procedures parameters.
after couple of hours when i restart the machine and again run the application it works fine with four parameters.
does sql server 2005 stores the parameters in cache??
if it does not keep it in cache then how come i get an error that values does not match the values in the stored procedure??
modified on Monday, April 28, 2008 10:30 AM
|
|
|
|
|
what is the equivalent of following C structure in c#
struct mystructure
{
int number;
char name[256];
};
Rajesh
|
|
|
|
|
Hi,
it depends on what you want it for. If it's just data being shared between two
pieces of C# code, then use:
struct myStructure {
int number;
string name;
}
and it will hold your data, whatever the length of the name string will be.
If on the other hand you want to share the data with code in another programming language,
or with a hardware device, then it will take more effort (e.g.with Marshaling attributes
or code) to match the requirements.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
actually i am writing some fields from webpages to file
using structure. then I read the file using same structure
in the c++ programme . in c++ no string data type so I cannot use string
in my structure
Rajesh
|
|
|
|
|
|
I am c# programmer and c++ site cannot change .it is already running and cannot change huge code there.
Rajesh
|
|
|
|
|
Fair enough then.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Three comments then:
so it is a binary file (because of the int) although probably most of the data is text?
I would make it all text then (hence use int.ToString and/or int.TryParse)
are you aware of character sizes? in C/C++ it could be 8-bit or 16-bit, on C# it will
be 16-bit.
Some people would recommend using XML for something like this. I'm still undecided.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
You can use a BinaryWriter to write the data to the file.
The .NET equivalent of a C++ char is a byte. If you have text to put in the file, you have to know what encoding to use to turn it into an array of bytes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
structure mystructure
{
int number;
string name;
}
The default for those variables in C# will be private (I believe), you will have to create properties to expose the variables.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hello everyone,
For the default approach for a console application or Windows service written in C#, if there is an uncaught exception, the console application or the Windows service will terminate? Right?
thanks in advance,
George
|
|
|
|
|
Gee - how easy would this be to find out for yourself ?
Yeah, the exception will reach the top level, won't be caught and your app will report an error to the end user.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian,
I am just asking for others' experience. "report an error to the end user" and program will terminate, right?
regards,
George
|
|
|
|
|
yes, it will terminate, but it will do so in an ugly way. Any app I deploy has top level exception handlers that write an error log to the hard drive, and tell the user about it ( and often, email it to me ).
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian,
Your reply is clear.
regards,
George
|
|
|
|
|
Hello everyone,
We can refer and use another type in a C# DLL file, but can we refer and use another type in a C# EXE file (build as executable)?
thanks in advance,
George
|
|
|
|