It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I get that mistake.. I use a loop to run through a bunch of images to be drawn..I also use multithreading..
What could cause that problem and how could it be prevented?
I use winforms
Additional information:
it tells me if i use graphics after GetHDv method, call the ReleaseHDC method..
What does it mean?
section of the code:
A thread created like this:
Before I did this:
BackgroundWorker1.RunWorkerAsync();
Now I am testing with this:
Backgroundworker back=new backgroundworker();
back.runworkerAsync();
is that the root of the exception?
According to this page
What's really happening with "Object is currently in use elsewhere" is
that GDI+ is complaining that the device context (DC) that it is
trying to use is already "in use". With WinForms, this generally
means there is a recursive Graphics.GetHdc occurring. GetHdc must
match a ReleaseHdc before any other GetHdc.
And
You can encounter this exception if you're drawing to a form from
multiple threads. You'll likely also be encountering a
cross-threading exception as well. The solution in this case is to
not use multiple threads when accessing a form, including drawing.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Is it possible to encounter Runtime error while using Generics? Could anybody give an
example?
public Someclass<T>
{
int i;
}
In what situation, this implementation can encounter an runtime error? Could anybody show any implementation by which the above class can encounter a runtime error?
The implementation you showed doesn't really do anything, so it, itself, is very unlikely to exhibit any runtime errors (other than a potential OutOfMemoryException on creation if you're out of memory).
If you had other code within the class, it, of course, could exhibit different behavior, and cause other errors to occur. Using this class, as well, could exhibit errors at runtime, but that error would technically be in the code that used the class, not arising from within the class itself, as this class has no methods defining behavior.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
After learning about state machines, I want to place it in every class of my code. That's a great pleasure for me to declaratively (or "fluently") construct a machine, handle events and be sure that any logic violation will throw an exception.
Can you please critisize me on this practice? Or, may be, you install Stateless package habitually for each project (like I do)?
Any examples of state machines overusing?
Whilst design-patterns are very good practice, you should be cutting code to solve a particular problem that potentially will use a design-pattern to solve that problem in a tried-and-tested manner.
We do not write code from a "let's use this design-pattern" perspective because a single design-pattern is not a one-size fits all solution!
Do not write all your code around the state machine idiom. It will make many simple tasks over-complicated and difficult to maintain.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am facing problem with "Access one xml file from 2 different applications at same time".
But it shows error code is "access denied, because another process using the file".
I applied all lock methods, but no use (same error).
Setting the correct FileShare enumeration value when instantiating the underlying FileStream allows you to control this.
Ref.: http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx
Even if it would be possible for two applications to write to the same file at the same time, the file would be corrupted. I recommend you to use a database instead.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have loads of static object in my application.
Want to check the memory usage of all static object , whether they are efficient to lie inside the memory from the time application is created (in mean once the application pool starts or its restarted)
don't want to use any of the tools or exe's , want to have my own Lib to check
Edit Post :
Need some simple way in the code , by which I would be able to trace the memory usage of static methods , members.
Using these parameters I would be able manage profiler / monitor for my system
you should use a profile because it is impossible to do is at runtime and bear in mind that the size of an actual object doesn't include the size of any objects it references.
A quick tip (but not accurate) could be to Serialize the object and check the buffer length which should stick to the object size
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I have a multithreaded code which is hang in some case. I want to know what's the recommended way to debug?
When it hangs, you can attach the debugger and inspect thread state, including callstacks, to your heart's content. Often there will be one (or more) thread(s) that is (are) in a wait state, and you might be able to work out why that is.
If the state is not self-explanatory at the time of the hang, you can resort to techniques suggested to provide context information for the preceding program flow.
Because it is multi-threaded, you can't debug such as setting breakpoints, trace the statements and pause to see the values of the variables. The only way in my opinion is to print to the console and see the status from there.