If you looked at the code carefully, you would have noticed that the if (InvokeRequired) block actually passes the current method as the parameter to Invoke/BeginInvoke. The current method will therefore get called again, but this time on the UI thread, as it was passed as the delegate to Invoke/BeginInvoke, and InvokeRequired will therefore return false.
You do understand what Invoke or BeginInvoke does, don't you? They help you execute the delegate, that you pass as the parameter, on the UI thread. Invoke will wait until the delegate completes, BeginInvoke simply posts it to the UI message queue and returns.
Either way, the UI thread executes the delegate - this is the "second time" that you are talking about. InvokeRequired will obviously be false, since it's the UI thread that created the control on which InvokeRequired is called.
Got a winforms / c# app that uses the webbrowser control to navigate to and then save off a screen capture of the given web site. Unfortunately, trying to run this in a batch is proving fruitless as the control throws up IE's various dialog boxes complaining of this or that, e.g. script error, unrecognized publisher, etc. Quite a few instances with different dialog / message boxes, and of course program execution comes to a halt until a human clicks OK, rendering it a bit useless for overnight batch processing.
I've played with all the options in IE, as well as the properties on the webbrowser control, to no avail. In fact, when I do something like disabling all downloadable content (activex controls, etc.), they do indeed get suppressed. Then IE gives me a dialog box complaining that it can't render the page properly because it the controls weren't downloaded!
Does anyone know how to rig this control to run in silent mode and suppress all Windows / IE dialog boxes and error messages? Or a different c# compatible approach to accomplishing the screen shots? I'd be most grateful for any enlightenment.
Actually tried it both ways, among other things, and neither suppressed that particular dialog (only one of many). Oddly enough, the MS doc says to set it to false to suppress the errors, which seemed like a typo, hence my trying both ways.
I've found through poking around that the IWebBrowser2 interface has a Silent property that's supposed to do what I'm talking about. However, having not spent much time on this sort of thing, I'm unsure of how to implement that interface on the web browser control. Probably COM 101 stuff, just haven't been there in C#.
I am writing an application that enable user to create HTML files
but all his formatting choices are saved in a CSS file linked to his HTML file I'm writting this file by using the StreanWriter class but I don't know how to read a specific element to edit it when user changed his design.
I am wondering what is the best way to automatically recalculate a value in a specific field.
I have on my form fields A and B these are bound to a MSSQL table and I have field C that is a result from A + B. is the way to recalculate field C to assign an on change event on fields A and B or there is another way where I can achieve this?
I am trying to avoid attaching an event on each field.
Use INotifyPropertyChanged in your property fields, and react to the change. If you take a look for an article on binding by Paul Stovell on using databinding in Windows Forms then you can find an example suitable for your needs.
Deja View - the feeling that you've seen this post before.
I would like to know how it is possible to insert in a combo box the text values of an enumeration object?
For example, consider the SymbolType enum object from ZedGraph.
I would like to browse the enumeration values and add them in a combo box in order to give to the user the possibility to select the symbol for the curve.
I hope my question is clear enough.
There is no spoon.
Last Visit: 20-Sep-19 14:57 Last Update: 20-Sep-19 14:57