|
If you block execution of the calling method right after you make the thread. My question to you is: Why did you make it another thread?
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Im firing up multiple async tasks, so its not just one thread.
its multiple remote services that are called async
and I need to wait for all of them to finish so I can pick up the result and process it and then finally return the processed result from my method.
|
|
|
|
|
Greeeg's answer of Join is what I would suggest you look into.
The Join method basically waits until other threads are finished before resuming executin on the current thread
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
If you go with a ISyncResult object with a delegate called through begineinvoke then you can use waitone and do the same thing...
There are multiple ways to do what the OP asked, which method to use is mostly based off of the context of what you are doing.
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
I have three threads that are trying to write events to a single event log -- with each thread being a separate source. Each thread creates an instance of the EventLog and uses eventLog.WriteLine() to post the event. In initialization each thread checks to see if its' source name is registered to the log. If it not, it registers itself. Then each thread creates an instance of the eventlog passing the logname and source name, after which a success message is posted to the EventLog.
The first thread establishes itself and its' events are getting logged without problems, but the other two threads are not getting their events written.
Any help would be appreciated.
|
|
|
|
|
At what point is it failing?
1.
LongRange.Shooter wrote: each thread checks to see if its' source name is registered to the log
2.
LongRange.Shooter wrote: If it not, it registers itself
3.
LongRange.Shooter wrote: a success message is posted to the EventLog
4.
LongRange.Shooter wrote: thread creates an instance of the eventlog passing the logname and source name
Working through the above list should help solve your problem.
You obviously have it coded correctly in the first thread - have you tried altering/controlling the order of these threads to check if the code is functional in the other two - i.e make the second tread do it's stuff first?
Just seen the thread below! It looks like you might have found the root of the problem.
Dave
modified on Wednesday, May 7, 2008 3:03 PM
|
|
|
|
|
I am trying to automate Excel from within my C# application, and am receiving the above error.
I have added a reference in my project to the Microsoft Excel 12.0 object library which adds the Microsoft.Office.Core and Microsoft.Office.Interop.Excel namespaces (but strangely not the the Excel namespace - this is is only added when I add a reference to the Microsoft Excel 5.0 object library).
I have downloaded the latest Primary Interop Assemblies (PIA) for Microsoft Office from the MS download site, and added the following code to my program as well:
using Excel;
I still get the error. I have run out of ideas!!
Any help much appreciated.
|
|
|
|
|
Instead of "using Excel;" you should have "Microsoft.Office.Interop.Excel;" or you can create an aliases for that like this: "using ExcelInterop = Microsoft.Office.Interop.Excel;"
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
"Cannot create an instance of the abstract class or interface 'Excel.Application"
You cannot create instances of abstract classes or interfaces... Also, I don't see how your question has anything to do with this title.
Excel is not the namespace, use Microsoft.Office.Interop.Excel.
Cheers,
|
|
|
|
|
Please me Remoting concept of dot net in detail
---
Regards
ilango gandhi
' Knowledge can only be got in one way, the way of experience; there is no other way to know.'
|
|
|
|
|
ilango gandhi wrote: Remoting concept of dot net
The concept is like taking two tin cans and linking them together with a string.
led mike
|
|
|
|
|
|
|
You have a habit of asking very general questions that could be answered with the use of Google. Please study the language, and then come back with specific questions.
|
|
|
|
|
Hi,
I need help to create something like a news ticker. I want text to scroll from the right site of the screen to the left. I've been playing around with a DoubleAnimation but than you won't get a continuasly stream of text and it won't show all the text that is my TextBlock wich is in a UserControl.
I don't wan't to use substring to remove characters because this doesn't give a smooth animation.
I'm using C# code in a WPF project.
Thanks
Kevin
|
|
|
|
|
KBou wrote: DoubleAnimation
KBou wrote: WPF
Oh, you did say it was WPF. I suggest using the WPF forum.
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 )
|
|
|
|
|
I have a service that launches multiple threads. Each thread has a unique purpose and thus they are unique sources. I have a successfully created log file named OneSource and I want all of the sources logging events to that log file.
Currently I have each thread initializing and accessing the EventLog with their own instances, the service itself does not do any logging. My first thread that I start successfully initialized and logs to the file but subsequent ones do not. Here is my eventlog initialization logic (some names were changed to protect the innocent :
#region Eventlog initialization
bool creationNeeded = false;
if ( !EventLog.SourceExists( "someSource" ) )
creationNeeded = true;
else if ( !EventLog.LogNameFromSourceName( "someSource", "." ).Equals( "OneSource" ) )
{
creationNeeded = true;
EventLog.DeleteEventSource( "someSource" );
}
if ( creationNeeded )
{
EventLog.CreateEventSource( "someSource", "OneSource" );
}
events = new System.Diagnostics.EventLog( "OneSource", ".", "someSource" );
events.WriteEntry( "someSource: Event log successfully started.", EventLogEntryType.Information );
#endregion
FYI: We had management constantly changing their minds on the log file to use so we had to add code to make sure that the old log was deleted before we used the new logfile name and source.
I see the initialization message from sourceOne, but not from sourceTwo or sourceThree. Nor do I see any logged messages from anything but sourceOne. Also...I see Information logged entries from sourceOne, but I never see anything logged where I use an AuditSuccess state for the log event.
Any guidance would be appreciated.
|
|
|
|
|
Wow, is that production code with all those string literals? Are you kidding me?
LongRange.Shooter wrote: I see the initialization message from sourceOne, but not from sourceTwo or sourceThree.
Well I don't see any string literals for anything but someSource and OneSource in the code you posted so based on that seeing anything else is just not possible, period.
ASIDE: The code you posted is horrible, literally.
led mike
|
|
|
|
|
Well, smartass, you don't see it because it is just the initialization code for someSource. The other initialization routines are the same, but someSource is replace with anotherSource, finalSource (for example). It is representative code of the initialization routine. And, BTW, in a recent technology testing I took I rated in the top 5% internationally as a C# coder.
So do you have anything helpful to add or do you just like hearing yourself blow crap out your mouth?
|
|
|
|
|
F*** off a**hole
led mike
|
|
|
|
|
LongRange.Shooter wrote: in a recent technology testing I took I rated in the top 5% internationally as a C# coder.
So was it an easy test then?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
No it was the Robert Half test, locally most got only 75% and internationally the average was 79% while I scored 92%.
|
|
|
|
|
Oh, I see. I've looked Robert Half up now, I didn't realise they were a recruitment agency, I thought they were a just a certification company, like say CompuTeach here in the UK.
Obviously their tests will carry a lot of weight in the development community
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Let me get this staight...someone who is a site MVP and appears to be much more experienced than you told you that your code was not good. Yeah, he could have said it better, but calling him names is going to get you ignored permanently.
LongRange.Shooter wrote: in a recent technology testing I took I rated in the top 5% internationally as a C# coder.
Don't make claims like this unless you can prove it.
|
|
|
|
|
Well, first of all I don't care who or what he is. He could answer the question or shut up. He did not answer the question nor did he behave in a fashion I'd expect of a site MVP. Secondly, his comment was one of a smartass not someone being helpful. Finally, my claim can be backed up by anyone that has access to the Robert Half testing scores...the results showed that locally here the average score was 72 and internationally it was 79 while I score 93.
As to more experience....I've not seen anything that indicates he has more experience than me, especially since I've been writing code for 30 years and he's only been at it 15 years. I was also in a group that was part of the C# early adapters program and was working with Microsoft in finalizing the language within Visual Studio. Being a site MVP just means he either has no job or no life so he can jump in and answer a ton of questions before anyone else. I've been on this site for many years, been help to many people and I always try to provide help and not criticism, except where some constructive criticism can be of help.
Finally with the exception of the use of the various literals in beta code, there is nothing wrong with my code that I can see. And if there was indeed a major issue with how I wrote the code I'd love to have some one point out what it is.
|
|
|
|