i will upload now some of my experiments.
i will upload now some of my experiments.
Download here -> Webclient: Web Client Sample
DownloadProgressChangedEventHandler is raised at 4KB (internet) 65k (local) with respect to DownloadStringAsync.
Even though I can’t consider this as complete Asynchronous Model, coz WebClient class uses Events and not AsyncCallbacks(they aren’t the same technically), everything are still done asynchronously. User can CANCEL (control whatever on the forms). Try dragging, or hold the UI as the download progresses or until it finished.
InvokeScript can be inserted or trigger anywhere on the DownloadProgressChangedEventHandler, if it requires to spawn another thread saving resources, call API, it is still possible, provided that you won’t break the UI Thread. A Combination of BackGroudWorker is useful for multiple threads.
My previous example of BackGroundWorker download it here -> BackGroundWorker Sample
Last edited by MarkCuering; 12-08-2009 at 04:23 PM.
@Mark - I appreciate you taking the time and effort to help me.
Ako gi try imo gi himo and yes dili siya mo kaging. Again ako pangutana is are you using InvokeScript to download a resource or something on that test app?
oopsss I forgot, another thing to prove that it runs async'ly, try click "navigate" button twice. Then hit "cancel".
of course, there's no way to cancel the previous call coz I disabled the button ^_^
another test... do this quickly.
1. enter site hxxp://www.mail.com -> hit navigate button
2. enter site hxxp://www.istorya.net -> hit navigate button
3. press "CANCEL".
result: mail.com display.
reverse the process.
1. enter site hxxp://www.istorya.net -> hit navigate button
2. enter site hxxp://www.mail.com -> hit navigate button
3. press "CANCEL".
result: istorya.net display.
If you navigate twice and cancel twice, both process stopped, it is good to know that during multiple process, when CancelAsync() method is called, the latest asynchronous call is aborted, the other remains running not unless you have an equivalent numbers of CanceAsync() calls.
Welcomestill learning here...
no problem with the invokescript (not tested), but it work on my custom thread, even multiple threads, I even spawn COM objects across the network to parse the data before it display on my textbox (that’s why it includes some proxy settings there)... if all of these works fine, then invokescript may still be fine, invoking scripts to do something that allows my UI to wait is the same, not unless if the script is modifying the UI. it's ILLEGAL! UI Thread should be the only one to update the UI...that's why a BackGroundWorker is helpful if you want to modify the UI outside from its own thread...coz it shift from other thread back to UI and vice versa, surely you won't violate any rules.
during my test I figure it out that something wrong with your “while” statement and the DoEvents(). Try to remove that or reconstruct your code... Honestly, I don’t understand why you place thatbut it looks no good to me. I used DoEvents() method only in some certain situations.
Coffee Time LOL....
This isn't something to prove asynchronousity (sakto ba kaha na nga wording nyahahah).
I don't why you are talking of COM Objects across network, its irrelevant to my problem.
If you don't understand why I placed DoEvents there, then we both have much to learnOriginally Posted by MarkCuering
![]()
hahahahahaha.... but i understand in my own application
from MSDN:
inside your WHILE statement you place DoEvents().When you run a Windows Form, it creates the new form, which then waits for events to handle. Each time the form handles an event, it processes all the code associated with that event. All other events wait in the queue. While your code handles the event, your application does not respond. For example, the window does not repaint if another window is dragged on top.
If you call DoEvents in your code, your application can handle the other events. For example, if you have a form that adds data to a ListBox and add DoEvents to your code, your form repaints when another window is dragged over it. If you remove DoEvents from your code, your form will not repaint until the click event handler of the button is finished executing.
1. WHILE is a kind of LOOP is it against to asynchrous call?
2. What happen if WHILE statement becomes FALSE? so no more DoEvents() call too
3. while (IsDownloadCompleted == false), you waiting here, and yet some delegates are waiting too
test my BackGroundWorker again... hehehe... actually I learn alot in your problem![]()
Last edited by MarkCuering; 12-08-2009 at 05:50 PM.
If you mean about the TESTGUIDE yes... asynchronous events are those occurs independently in the main program. We only add button to control them "NAVIGATE” and "CANCEL" base in my example program. When you navigate two sites, and cancel one, you can still get the first result.
If it were synchronous call, all of it will be aborted… what I’m trying to test also is raising more than 5 calls then stopped the middle… oops...sorry this is not related to your problem![]()
instead of invoking script I use also some COM Objects... I'm not a web guy... I don't have the right knowledge to write reliable javascript or jscript![]()
Yep. Mao nga ang title sa thread is "... executed in another thread?" Pero sa muna-munang paningkamot nga dili kaayo ma complicated ang app, ni adto nalang ko sa event based solution para ma solbad na ni.
Instead nga mag paabot ang script sa result sa "GetContents", ako nalang gi pa register ang scripts ug function nga tawagon sa app once mahuman na ang download process. Di unta ko ganahan ingon ani pero saon mao ra man solution ako nakit-an sa pagka-karon.
Kung naa mo idea nga mas maayo and simple, open japon ko para maminaw. Salamat sa inyo tanan!
Similar Threads |
|