Re: How do I turn off write combining programatically?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for the ideas.

The write combining thing, is what I read on another site where a fellow was
having issues and others advised him to turn off write combining, because
the combining, and this is Microsoft's own words, the combining is fast, but
it does not guarantee that the batch of commands will be processed in any
particular order, so it's not a Fifo cache. If a sequence of commands
expects needs to be done in a particular order, you may have issues. He said
it helped in his case.

I have debuggers wherever it draws. I am not sure what ye mean about locking
the control, but I do like the idea that there might be extraneous paint
events. I have an if statement, in the paint event, that will not process
any of my drawing stuff IF my code initiated it.

I used to just use the PaintEvenArgs.Graphics object to do the painting,
with this style ...

SetStyle

(

ControlStyles.AllPaintingInWmPaint // Name explains it.

| ControlStyles.Opaque // Background is taken care of by DrawImage.

| ControlStyles.UserPaint // if Allpainting is on, so must this.

| ControlStyles.DoubleBuffer // Use the native double bufferng.

,true); // this sets all the above styles to true.

This is supposed to make it so I only am painting, but I notice inexplicable
pauses, unless I turn off Write Combining.

Interesting URL there too, I am going to go see it. I am thinking that maybe
I should not bother with GDI+ and try the DirectX drawing stuff. Maybe that
will not have these horrible issues.

I've considered, trying to set up some sort of user defined event where I
can have the form tell my main loop via an event to fire off, my drawing
when it's done.

I put a lock on the PaintEventArgs.Graphic object and that was no help.

Now, I just do something like this in paint event ...

Graphics grTemp = e.Graphics;

DoSomeDrawing(grTemp);

grTemp = null; I tried grTemp.Dispose() but the program would not draw when
I did that because it disposed of the actual e.Graphics object as I
suspected.

I've switched to using GraphicPaths to do the drawing faster, anything I can
do to limit the time I spend drawing I think is a good thing. I also have
code that checks to see if the paint is finished before initiating another.

Anyway, thanks again for the ideas and suggestions.

"Frank Hileman" <frankhil@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23ydei8TcFHA.2424@xxxxxxxxxxxxxxxxxxxxxxx
> The problem may have nothing to do with write combining.
>
> If you make some sort of illegal drawing call, which is very easy to do
> with GDI+ (try drawing a line with 0 width and height), an exception may
> be thrown. Any exception thrown while drawing with a Graphics will tend to
> corrupt the Graphics. Later on, any drawing operations on that Graphics
> will result in object in use elsewhere. Try attaching a debugger that will
> break when an exception is thrown.
>
> I think this can also occur if you use CreateGraphics and are not careful
> about locking the control to prevent a paint event from being processed at
> the same time you are updating the screen in other ways.
>
> I don't know about screensavers, but depending on your Control is hosted
> you may also get Paint events on illegal (non UI) threads -- this happens
> when hosting in IE, for example, and is a completely undocumented
> bug/feature. It is up to you to work around this Microsoft bug with
> explicit locks. To see if this is a problem, put a break in the paint
> handler and see how many threads are running. If a paint occurs outside
> the UI thread, you have a potential problem. Or perhaps you are not
> calling Refresh on the main UI thread?
>
> In general, you should never cache any Graphics, except a Graphics for a
> Bitmap, and if you cache a Graphics for a Bitmap, you should throw it away
> if an exception is thrown.
>
>
> Regards,
> Frank Hileman
>
> check out VG.net: http://www.vgdotnet.com
> Animated vector graphics system
> Integrated Visual Studio .NET graphics editor
>
> "Garry Freemyer" <garryfre@xxxxxxxxxxxxxxxxxxx> wrote in message
> news:edgVKRTcFHA.1384@xxxxxxxxxxxxxxxxxxxxxxx
>> Using C# Visual Studio Net 2003, my screensaver comes up with this
>> amityvillehorrorInvalidOperationException error "Object in use
>> elsewhere", and I can't fix it!
>>
>> I read that a work around is to go to Display
>> Properties/Settings/Advanced/Troubleshooting and change the settings
>> there and it seems that "Write Combining" might be be the culprit. It
>> caches writes to the screen and when the cache is full enough, it send
>> the commands in one batch!
>>
>> This might be why I'm getting this error from h^ell. The error take
>> anywhere from 20 seconds to 18 hours to show up. I can't catch it in a
>> catch clause and I'm so sick of seeing it that I'm ready to erase my
>> screensaver, and my posted sample in sheer disgust and destroy all source
>> code!!!
>>
>> Puhleez!!! Is there a way to turn off this in my program so I don't have
>> to go in and mess up the performance of every game I have just so I don't
>> have to scream and shriek at this error? I don't ever want to see it
>> again!
>>
>> I've seen it at least 80 times, and I'm sick of it!
>>
>> Sorry for the rant, its just that I've fed up with this issue 5 million
>> times over!
>>
>> --
>> To reply to this message take off the .NoJunkSpam off of the end of
>> garryfre@xxxxxxxxxxxxxxxxxxxxxx
>>
>
>


.



Relevant Pages

  • Re: How do I turn off write combining programatically?
    ... GDI+ (try drawing a line with 0 width and height), ... Any exception thrown while drawing with a Graphics will tend to ... Bitmap, and if you cache a Graphics for a Bitmap, you should throw it away ... > screensaver, and my posted sample in sheer disgust and destroy all source ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Blank string to number
    ... Once you no longer need it for that purpose you should probably dispose of it, if only so that you know where and when you are disposing of it. ... If you will always have an image of some sort or another to be drawn on that form, then the image object does not need to be disposed - just re-use it for the next drawing. ... > This automagically disposes the graphics object. ... If you are drawing to the Paint event graphics object you are not persisting the graphics - you are re-creating them each time they need to be displayed. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: When minimized, Graphics hides
    ... I've made a simple app to train using the class Graphics. ... property FormBorderStyle I've set as "None", ... The proper place to do drawing is in the Paint event. ...
    (microsoft.public.dotnet.general)
  • Re: Graphics Vanish when Window is Over
    ... Ok, basically, you need to do your graphics in a paint event. ... do them in paint events or don't call your drawing stuff from paint events, ... > I am developping a multiple forms Windows Forms application in Visual ...
    (microsoft.public.vstudio.general)
  • Re: /boot/loader graphics support & extensibility
    ... and drawing filled rectangles (e.g. to clear the screen ... and different graphics hardware supports ... The Forth code calls the rectangle function. ... what will be the bitmap format of the temporary ...
    (freebsd-hackers)