|
The alternative problem situation is a race condition: say you start a very short thread and clear a flag (a bool or a ResetEvent) then wait for the flag getting set; whereas the right order would be clear the flag, start the thread, wait for the flag.
By optimizing stuff the thread becomes faster and may set the flag before you clear and then test it.
|
|
|
|
|
Also nice suggestion, it's happening in this order: create and clear flag (new ManualResetEvent(false) ), create (new Thread) and start thread, the thread runs and eventually sets the flag (Set() on the resetevent)
After starting all threads in this way it begins waiting for the threads.
Old ResetEvents are just discarded.
Is that right?
|
|
|
|
|
That is right if executed once; and it may be right if inside a loop.
If both sides contain a loop and need to synchronize each iteration of it, then I consider it bad style to create new ResetEvents (or whatever synchronization object) all the time, since one party could be manipulating the old/new object whereas the other is manipulating the new/old object (which they probably share through a shared variable, say a class member) probably leading to a stand-still.
I would suggest you add some logging: let your threads report somehow what they are doing. I always have a protected void log(string s) method present in all my classes, it's implementation could be as simple as Console.WriteLine(s); or could be somewhat more complex, possibly with the current time, the current thread's ID, optional file output, etc.
Seeing the system-wide actions in chronological order helps in debugging, much more than breakpoints and other fancy stuff if you ask me. The Visual goodies are more suited for solving very local problems, once you now about where they are.
|
|
|
|
|
It normally happens 3 or 4 times, a bit spaced out, not as a loop.
I will add logging now
|
|
|
|
|
Did you try attaching and breaking into the debugger (Debug -> Break All) once the application becomes unresponsive?
|
|
|
|
|
I would like to, but the problem doesn't occur during debugging
|
|
|
|
|
You don't really need to be debugging. Just build the application in release mode with debug information, run the app then and attach it to the debugger. AFAIK, the debug/release detection is done based on the app launching your app, so as long as you don't run your application from Visual Studio, you should be able to reproduce the problem.
|
|
|
|
|
How do I attach it to the debugger?
|
|
|
|
|
If you are using Visual Studio, Debug -> Attach to Process
|
|
|
|
|
That does not exist
Maybe it's in Pro only?
|
|
|
|
|
Ah, you're using the Express edition?
|
|
|
|
|
Yes
|
|
|
|
|
If you're desperate enough, you can use the freely available Windbg/SOS[^] to debug the issue. I can walk you through the steps if you're interested.
|
|
|
|
|
Very kind of you, but the problem magically disappeared so it kinda moved to the bottom of the pile.. Until it resurfaces of course
|
|
|
|
|
hi every one
i am trying to add a row of one datagridview to another with this code
selectedheadgroup.Rows.Add(datagridheadgroup.Rows[e.RowIndex].Clone());
and there is a problem cells are blank
and try with this code to fill cell
selectedheadgroup[0,selectedheadgroup.Rows.Count-1].Value=datagridheadgroup[e.ColumnIndex,e.RowIndex].Value.ToString();
this codes run but cells are blanks!!!!
whats problem ?
help me please
help me emergence
thanks a lot
|
|
|
|
|
I need to reference some buttons that are in a PDF so that I can write an event handler for when the PDF button is pressed. I do have acrobat SDK, but am unfamiliar with how to reference the buttons within the PDF at runtime... Has anyone here tried to make a button press event in a PDF become an event in the windows app??? BTW, the PDF will be opened through the Adobe REader in my PDF, so it will be open within my app... I haven't found a way yet to reference the buttons within the PDF though, or subsequently create an event for their button press.
It might be a simple help if someone could tell me if there's a way to open acrobat in a viewing window just like the adobe reader window in a C# app. Or is there a way to reference the file displayed in my PDF REader window as a "CAcroAVDoc" object. I'm beginning to think there's no way for the READER control to convey what button is pressed to the C# app. But I bet it would be easy with the full version of Acrobat. But I don't know how to get an acrobat window into my windows app like i can the adobe reader. Does this make sense to anyone???
I'm kinda new to this...
modified on Friday, April 17, 2009 1:45 PM
|
|
|
|
|
You can open a pdf window inside a winforms app using this[^] but I'm not sure that will help you if you want to use the information in you app that you have clicked on.
A better method would be to get an open source pdf library from sourceforge: here[^]
|
|
|
|
|
I have several of the open source libraries now available to me. I have looked at many of the examples, and there is an issue that I have not yet been able to resolve. Can you open the document in the Adobe Reader, but reference it's button click events through one of the other libraries??? I'm having a hard time figuring out how to identify it as an object of another library if the document is in the Adobe Reader. All of the examples are opening documents in their own adobe windows. I can't find a way to reference one in my Active X control....
Again, I'm new at this.
BTW, does anyone have a link that will give me a quick rundown of what I'm looking at exactly when i download a library... I'm looking at folders without a clue of what they mean (bin, debug, release)...and i'm not sure about what all of the implications are behind file extensions(.cs, .dll, .csproj, .sln). I was hoping to find a tutorial or something to put it all together. (I'm trying to learn Visual C# with a strong background in VBA for excel. This means i understand syntax and stuff like that alright, but i'm still having a hard time with the framework of it all.)
|
|
|
|
|
When you download a library these are the file types:
*.cs = c# file can be opened in notepad but opens as default in Visual Studio
*.csproj = a c# project file
*.sln = a solution file to be opened with Visual Studio which opens all the .cs and .csproj related to it.
*.dll = dynamic linked library. The compiled project.
release folder should contain the .dll or .exe which is the finished compiled project
debug is where Visual studio places compiled projects when they are being tested(debugged)
Sorry I don't have any more info on your problem. I've never had to do it before ![Sigh | :sigh:](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_sigh.gif)
|
|
|
|
|
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.IO;
using System.Data;
using System.Reflection;
using System.Data.Common;
......
static void Main()
{
Application.Run(new FormCerca());
string aPath1 = System.Windows.Forms.Application.ExecutablePath;
}
why do i get the COMPILE ERROR
'System.Windows.Forms.Application' does not contain a definition for 'ExecutablePath' ??
Thanks
|
|
|
|
|
IFDTCACT wrote: why do i get the COMPILE ERROR
'System.Windows.Forms.Application' does not contain a definition for 'ExecutablePath' ??
Er..... that would mostly be because System.Windows.Forms.Application does not contain a definition for ExecutablePath .
It does, however contain a definition for StartupPath , which may suit your needs.
BTW is your Intellisense not working?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Thanks.
And there was me thinking an MS compiler would get it right.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I just tried in on VS2005 and didn't have a problem:
using System.Windows.Forms;
.
.
.
Debug.WriteLine( Application.ExecutablePath );
Verify you have a reference to System.Windows.Forms.dll.
Try Cleaning the solution, then do a full rebuild of the project.
|
|
|
|
|
Thank You
I found the problem raises from the version of references
I referenced Old Compact Framework in tha project, taht was originally built on Version 1.1 .
SO the right way is to remap references..
thanks everyone
|
|
|
|