|
|
So on every block I think it is better to do
myTimer.Elapsed -= new ElapsedEventHandler(Method);
myTimer.Elapsed += new ElapsedEventHandler(Method);
By this way even if this block is running more than one, everytime it will remove the eventhandler and then add it. Provided, if you are unsure that this block will run more than once.
|
|
|
|
|
Thank you, that is a nice way of doing it too.
But I solved it with adding a global int called Session with default value 0. And everytime I get this adding ElapsedEventHandler if this session is greater than 1 I don't add it.
|
|
|
|
|
yes .. this is a possible way...
nice to hear that you solved it.
Cheers.
|
|
|
|
|
Ummm... what? I didn't understand what you were trying to say.
What are you trying to accomplish and what problem are you having?
|
|
|
|
|
I had a timer which I stopped and started some time later. But when I started it for the second time it was doing what it was doing when ticked twice. It turned out that I was adding new eventhandler twice
|
|
|
|
|
So in the end this article[^] is about you?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Seems that way.
|
|
|
|
|
I've got simple console C# project that calls unmanaged DLL with Interop. I need to step into native DLL function either from C# or debug native DLL and break in C++ debugger.
I set up Enable unmanaged code debugging in C# console.
The DLL function is called correctly, e.g. it prints the message to console.
But as I run DLL with F5 and it invokes C# console, the break points do not work.
Nor can I step into DLL unmanaged code from C# console
Чесноков
|
|
|
|
|
|
that one worked, 'Enable just my code debugging'. Great!!!
Чесноков
|
|
|
|
|
however you still can not run native DLL which is invoked in C# and stop at bps in DLL project
Чесноков
|
|
|
|
|
I've got all setup as described and was debugging native DLL normally, while on the other project run it just stopped stepping into the native DLL?
What happened as I did not touched the settings they were before???
Чесноков
|
|
|
|
|
Hi, I have a small application that is exhibiting an AccessViolationException before it even enters Main(). I found this out after the pilot in our production environment started failing from time to time - it would enter some infinite loop somewhere at the end of Main() after all useful code has been executed. I found the access violation when running the app in the debugger.
The tricky bit is that it does not happen in controlled source code (the failure occurs before I reach Main()) so the actual issue is difficult to determine. I would suspect some kind of stack overflow but do to know how to troubleshoot this in Visual Studio. The app is in C#. Any suggestion to get started?
|
|
|
|
|
Maybe one more detail: it is a console app and is complaining about a Windows Form (in an attempt to issue a SendMessage()).
However, I do not have explicit instantiations of a Windows Form... Weird...
|
|
|
|
|
How about in project properties -> output type ?
It must be "Console Application".
|
|
|
|
|
It is. .NET target is also set to 2.0 for the production environment.
|
|
|
|
|
Have you tried to reinstall .NET Framework and run it as administrator ?
|
|
|
|
|
Mmmhhh... interesting thought. No, I haven't. However, I have already 2 machines with some kind of symptom. The production environment is under .NET 2.0 and my machine under 3.5. The project targets specifically 2.0.
Hope this helps
|
|
|
|
|
My developing PC is also .NET 3.5 with VS2008, and the production system is XP with .NET 2.0.
It works great... without any problem.
|
|
|
|
|
It worked for me too at the beginning - that's why I don't think this is the issue.
It sounds like I'll have to create a new project and import my current code until it breaks...
|
|
|
|
|
Hi,
your static Main() method is inside some class; the static constructor of that class, if any, will run first.
As a console app, chances are all/most/large parts of your code are in that class. I suggest you move them out, keep the class containing static Main() as simple as possible, put everything else in another class, either static or instantiated once. That will ease your debugging.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Sounds like a good plan. Yes, I have a few things in the main class. I'll have a look tonight.
Thanks!
|
|
|
|
|
Hi Luc,
In the end, I tried to create a new console project with just an empty Main() and tried to step into it - I can't figure out how to remove more from the main class... I tried to step into Main() and had the same AccessViolationException error about Windows.Forms. So I gave up and am trying to reinstall VisualStudio. It's weird... and I could have a better use of my time then trying to correct M$ errors... I'm under Vista SP2 (well, Windows still thinks that it is under SP1 - the machine is brand new and Windows is having problems since I tried to load SP2). Just hope I won't have to reinstall the whole machine from scratch.
|
|
|
|
|
I would run first outside Visual Studio, and try on a second PC. If it behaves badly outside VS and only on one machine, then I would reinstall the .NET Framework on that machine, rather than reinstalling/fixing VS.
If it runs fine outside VS, or badly on both machines, then I would reinstall VS.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|