|
Hello All...
Do U know how to work with Group Policy in C#.
Any Samples or Docs...?
Thx 4 reading
Enjoy...
Siddharth
|
|
|
|
|
Hi
Been working with C# a lot, but strangely enough, not very much with threading. I guess my question in someway touches that area.
My problem is the following. I want to perform a series of tasks with a single webbrowser. Each task should consist of the following: 1. Load a document from the internet, 2. Analyze the document and store some data.
To do these things for each task is no problem. However, as a series of tasks is queued, some trouble occurs. To load a document I use the Url property of the webbrowser, and the code to analyze it is placed in a method being executed when the DocumentCompleted event is fired. This is placed within a class called BrowserTask. To perform a task, BrowserTask's Perform method is called. This method sets the Url of the browser. However, the method call is ended when this is done - which is not what I want. I want the method call to end after the document has been completed (and analyzed), meaning it should wait for DocumentCompleted event.
Seems like a simple task to me, however i have googled my ass of trying to find a solution to this problem, without finding anything helpful.
Help would be very appreciated.
Thanks!
|
|
|
|
|
Hi,
just like all "completed" and "received" handlers, DocumentCompleted executes on a separate thread.
So you could use an AutoResetEvent() and apply a WaitOne() which keeps your business logic from running ahead; then have a Set() in the DocumentCompleted handler, allowing your logic to continue.
I foresee one major problem though: I have experienced DocumentCompleted is not trustworthy, a web page may call other (sub)documents and some or all of them fire DocumentCompleted, so you will have to see if that happens, and try and figure out a way to determine the entire page has loaded...
Maybe you don't need to see the WebBrowser control, and you then could consider, as a last resort, to create a new one after every (problematic) page.
|
|
|
|
|
Thank you Luc!
I couldn't figure out how to use an AutoResetEvent though. However, I found the following solution, which seems to work:
WebBrowser browser = new WebBrowser();
bool loaded = false;
browser.DocumentCompleted += delegate { MessageBox.Show("loaded!"); loaded = true; };
browser.Navigate("http://www.facebook.com/", false);
while (!loaded)
Application.DoEvents();
Maybe not a very nice one? How would i use an AutoResetEvent instead?
Thanks /Viktor
|
|
|
|
|
your while loop is keeping an entire core busy, not a nice thing to do.
AutoResetEvent, just like all .NET classes, is documented in MSDN.
The first page on the topic contains an appropriate example in the Calculate class.
|
|
|
|
|
Luc Pattyn wrote: your while loop is keeping an entire core busy, not a nice thing to do.
True. But with a simple modification this solution might still be enough:
while (!loaded) { Thread.Sleep(100); Application.DoEvents(); }
Obviously this means an average latency of half the sleep interval between the loading completing and the thread continuing, but it will not use a lot of resources (provided a relatively long interval like 0.1 seconds). Threads normally go to sleep and wake up rather more often.
You may already know this, but you also don't *need* to call Application.DoEvents() in order for this to work. You DO however need to call it if you want the application to remain responsive while this is going on. Also, if you use an autoreset like Luc suggested this will put the main window thread to sleep and thus result in an unresponsive user interface until the loading completes. Depending on whether this is some tool you will use yourself or something pushed to actual users this may be acceptable some of the time, but I would think you'd find it unacceptable once there's a network problem or the server you contact just doesn't respond for a long time.
|
|
|
|
|
If the code you have posted is on the main UI thread (and it should be as otherwise you should not call Application.DoEvents ), the problem with using an AutoResetEvent or Monitor.Wait and Monitor.Pulse is that it will put the UI thread to sleep until the operation completes and thus produce a very unpleasant unresponsive application. It won't cause the application to crash, but it will seem like it has if a network problem occurs or a server is very slow to respond.
The question is why do you need any synching at all? The WebBrowser already provides a mechanism in the form of the event, so if step one is to download a document and step 2 is to scrape it, then why not just call scrape() from within the completed handler?
There is at least one problem with this though; it's a bit tedious to update the UI from threads other than the main UI thread, because you have to marshal the calls using Control.Invoke . It's not difficult but it is a bit ugly.
|
|
|
|
|
Hi,
if you don't need to see the web page, you should not use a WebBrowser at all; just use the HttpRequest class.
[EDIT] That will give you the page you ask for without loading all the referenced objects, such as images.
[/EDIT]
modified on Thursday, April 16, 2009 8:00 AM
|
|
|
|
|
Hi Guys,
I'm having problem with getting my TreeView check boxes working as intended. I've got a set of root nodes for Groups, and all child elements belong to that group. I'm only interested in enabling check changing for child items, and changing the group check state should be prevented.
I have overrided the OnBeforeCheck and OnAfterCheck to perform the desired bahviour, However, by double clicking on an unchecked check box, the check state is changed, and i get nothing in either OnDoubleClick, OnNodeDoubleClick and no Before/After check events. The OnDoubleClick and OnNodeDoubleClick are raised when going from Checked to Unchecked.
Ideally i'd like to disable or hide the 'group' node check boxes
Does anyone have a solution for this?
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
The only thing I can think of that might work is to override the two doubleclick event handlers and test for the Level of the node, passed in the eventargs, if Level == 1 (or whatever), return, otherwise do base.onWhatever. THis of course will only work if all of your 'group' nodes are at the same level.
It would look something like:
private override void OnDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Level == 1)
{
return;
}
base OnDoubleClick(sender, e);
}
Hope this helps.
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.”
|
|
|
|
|
Hi Henry,
Thanks for the reply, but i've tried overriding the OnDoubleClick and OnNodeDoubleClick and neither of them are called when double clicking a node, except when going from checked to unchecked.
I will see if i can make it reproducable and submit a project to MS.
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
I am busy designing an upgrade 'wizard' for our web application, as was wondering if a .NET Woikflow project would be suitable for this? The application needs to perform three main tasks, viz. obtain configuration information, upgrade the database by running one or more scripts, and upgrade the web application by replacing files. More tasks may and probably will be added to the application later on. I'm looking for a task based, sequential flow type design, with a minimal, shared interface for all tasks.
A full-on Workflow application may be overkill, but if it provides a feasible to use, ready made and tested task structure, why should I not use it?
|
|
|
|
|
|
Thanks Pete. That deserves a good looking at. I've often coded along those lines without being aware that the tactic was 'formalised' as a design pattern.
|
|
|
|
|
Hi,
We have a WPF Windows Application and this application would be used by all our client having VISTA OS. For any error occured, system will create an entry in Application event log using the custom event source - "Application Manager". When the User Access Control (UAC) is turned ON, VISTA does not allow to register custom event source in the registry. But this works well when the UAC is turned OFF.
Is there any way where in we can create a custom event source (on the fly/programatically) with UAC turned ON?
Note: Our application gets installed using "Click Once".
Regards,
Vipul Mehta
|
|
|
|
|
Unfortunately, your app needs to be running with elevated privileges to
create a custom event log.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi,i am new developer in vb.net.i have using vb.net2.0 and ms access.actually i am doing project on college student's attendence. a getting all the connection and at all but a would like to knoe the DATE difference parameter query for the attendence report by 'TO DATE to FROM DATE'.
|
|
|
|
|
If you want to know the diffarence between two dates you can use following sql function
DATEDIFF ( datepart , startdate , enddate )
refer following link also
http://msdn.microsoft.com/en-us/library/aa258269(SQL.80).aspx
|
|
|
|
|
Hi
My VB.NET Library references ADODB. When I build it, the above message comes out.
Should I run tlbimp.exe ?
Thanks
Marcello Turnbull
|
|
|
|
|
Sounds like you have signed your assembly, and that .NET wants you to sign the assemblies that you have referenced also.
Does the message go away if you build it without the signing-key?
I are troll
|
|
|
|
|
Hello friends.
I want to create an application in .net or VB 6.0 to search file in my systems. file may be Word, Excel or PPT.
As in Windows Xp it is inbuilt file searching option but still i want to create an application like that. By which i can be able to search my files using the contents based. Any body please help me and if you have the code please mail me at anandbpsri@yahoo.co.in
with regards.
Anand Srivastava
|
|
|
|
|
Did you read the sticky? The first thing it says is don't post and ask "do you have the code to do this or that". People are very helpful here, but nobody likes a parasite.
|
|
|
|
|
Hi
i got problem in setup project welcome dialog to get new line in welcom text. am not getting new line here. How cani get new line in welcome text.
Thanks in Advance
--Naren
|
|
|
|
|
Hi Friends, In my project, i am using two classes suppose A and B. Class A contains two functions suppose SetInputF1 and SetInputF2 with same code and same return type just differ in function name (both functions are used to assign input values of class A to static global variables), and class B contains one function suppose f3. SetInputF1 is called by many functions.
Now if i call SetInputF1 in f3 then the values of static global variables are not setting properly and if i call SetInputF2 in f3 then values are setting properly. I am using SetInputF2 function only due to this problem. But due to this my code length is increasing. How to overcome this problem , please help me if you can...
http://nnhamane.googlepages.com/
|
|
|
|
|
One more thing, SetInputF2 function is not called by any function. If i call SetInputF2 function in any other function then same problem occuring as with SetInputF1 function.
http://nnhamane.googlepages.com/
|
|
|
|