Page 3 of 6 FirstFirst 12345 ... LastLast
Results 21 to 30 of 54
  1. #21

    Hmmm, sayop tingali ko pero sa akong sabot ang WebClient kay nagamit ra gihapon sa WebRequest ug WebResponse.

    Imo gi sunod akong steps? Lahi ra man ang Sleep vs sa actual call sa WebClient.

    Unsa nga online API?

  2. #22
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    The WebClient runs on the UI thread, so any outside calls/modification from the UI thread, it will freeze, not until the outside process is done.

    What client.DownloadProgressChanged is doing? Try mo daw remove yan, or try to remove the “this” keyword.

  3. #23
    Quote Originally Posted by junkfactory View Post
    WOhoo!! Sorry sa dugay reply mga bro! Party time man gud diri mao lipong2x pirmi.

    Background lang ni sa ako little project. Some istoryans may know who I am so please hush hush . I also think some of you might be interested in this little project and could use the ideas as well.

    The idea is to create a scriptable windows form based application.

    Scripting language chosen is javascript. The application exposes an API for script usage.

    The script can control all and any aspect of the form. Scripts needs to download any other resources from the INET, read local files, prevent closing of the form, display form messageboxes (not js alert()), report progress ... etc so these are done through the API.

    There can be one or more scripts that can interact with the form or interact with its fellow scripts.

    A webbrowser control is needed because the scripts can/needs to create html elements (forms and all web element stuff).

    So back to the problem.

    Right now, I scrapped the threading and sticked to a single thread momentarily. I have traced down to the very first call of Document.InvokeScript. Further down, a script calls one of my API functions "GetContents(url)" to download a resource from the NET which is using WebClient.DownloadStringAsync(url).

    Code:
          
    public string GetContents(string url)
    {
                    //snip .......
                    WebClient client = new WebClient();
                    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                     client.DownloadStringAsync(new Uri(url), this); <-- Main form freeze momentarily here but only of very first call!!!!
                     Application.UseWaitCursor = true;
                    while (IsDownloadCompleted == false)
                    {
                                    Application.DoEvents();
                    }
                    Application.UseWaitCursor = false;
                    client.Dispose();
                    return this.Contents.Context(ctx);
    }
    Now examining the thread executing WebClient.DownloadStringAsync(url), obviously, it is the main UI thread that's why I used the asynchronous method. But why does it freeze there? (marked in red). It is supposed to continue to the next instruction right? Or am I missing something that the framework needs to initialize some stuff?

    @Artoy, thanks for the idea, but using a delegate will cause the delegated function to be called on main thread which I think is the same as directly calling the Document.InvokeScript from the main form in this particular situation.

    @Mark, thanks I tried your test app. It appears the background worker works but I'm not totally sure because it completes very fast.Maybe you can try the real scenario I mentioned above? If you're up to it

    P.S. I'm just learning .NET so pardon my ignorance in some matters.
    For debugging/investigating purposes, can you comment this statements :

    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_Downloa dStringCompleted);
    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_Downloa dProgressChanged);

    Have you tried checking on a local webserver? If you have installed a webserver in your pc, kindly check it first.

  4. #24
    @eax - same result, mo kaging kadyot inig tawag sa client.DownloadStringAsync(...) with or without the event handlers. Also, the app does/will/must not need a local webserver.

    Murag naay ginabuhat ang framework internally ambot kung unsa. Di man sad pwede e singleton nako ang webclient kay possible man (unya puhon) naay concurrent scripts mo call sa "GetContents".

  5. #25
    Quote Originally Posted by junkfactory View Post
    @eax - same result, mo kaging kadyot inig tawag sa client.DownloadStringAsync(...) with or without the event handlers. Also, the app does/will/must not need a local webserver.

    Murag naay ginabuhat ang framework internally ambot kung unsa. Di man sad pwede e singleton nako ang webclient kay possible man (unya puhon) naay concurrent scripts mo call sa "GetContents".
    That's weird I've tried ang imong code without the event handlers okay man diri sa akoa. Maka-download man siya. Have you tried using a web-debugger(i.e. Fiddler Web Debugger - A free web debugging tool, http://www.charlesproxy.com)? If yes, try kuno ipa-agi imong application sa web-debugger kung maka-connect pa siya sa internet. I-set lang as proxy sa imong code ang web-debugger(i.e. localhost:888. Chances siguro ana is wala siya naka-connection mao na mo-hang siya.

    Naa pud lain is mag-butang ka ug mga connection timeout, socket timeout, etc. sa imong code. Para automatic siya maputol/release kung mag-timeout siya. I doubt murag wala nay connection sa internet ang imong application? Sa office ka ba nag-work ana? If yes, nag-gamit ba mo ug proxy sa inyong internet browsers?

    Ang gamit sa local webserver is to check kung mo hang gihapon siya.At least ni-connect ka wala nigawas sa network. Kung okay gani sa imong local webserver chances are dili imong application ang naay problema ang network nimo.
    Last edited by eax; 12-08-2009 at 08:36 AM.

  6. #26
    Quote Originally Posted by eax View Post
    That's weird I've tried ang imong code without the event handlers okay man diri sa akoa. Maka-download man siya. Have you tried using a web-debugger(i.e. Fiddler Web Debugger - A free web debugging tool, http://www.charlesproxy.com)? If yes, try kuno ipa-agi imong application sa web-debugger kung maka-connect pa siya sa internet. I-set lang as proxy sa imong code ang web-debugger(i.e. localhost:888. Chances siguro ana is wala siya naka-connection mao na mo-hang siya.

    Naa pud lain is mag-butang ka ug mga connection timeout, socket timeout, etc. sa imong code. Para automatic siya maputol/release kung mag-timeout siya. I doubt murag wala nay connection sa internet ang imong application? Sa office ka ba nag-work ana? If yes, nag-gamit ba mo ug proxy sa inyong internet browsers?

    Ang gamit sa local webserver is to check kung mo hang gihapon siya.At least ni-connect ka wala nigawas sa network. Kung okay gani sa imong local webserver chances are dili imong application ang naay problema ang network nimo.
    Aws syalan ba diay, mao diay na pasabot nimo pagamit sa webserver chori.

    Possible sad na siya nga medyo nadugay siya ug connect, pero gi try nako sa local webserver, same result man.

    Ang kahibulngan lang nako is nganong sa first call ra gyud mo kaging kadyot, bisan pa lahi2x na nga url ang gi contact niya sa succeeding calls, mo sirit naman siya. Sa pirmero ra gyud. faet

  7. #27
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    I tried both WebClient, and WebRequest/WebRequest all works fine. Are you willing to rewrite your codes? are you sure it really freezes on this line client.DownloadStringAsync(new Uri(url), this)? i will upload another version later.

  8. #28
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    can you build and upload it too? so I can test it here also.

  9. #29
    that is a good idea.
    so far ok ra xa sa ako gtest...or sakto ba ni ako nabuhat..hehehehe

  10. #30
    Cge upload nya nako ako prototype inig abot nako sa balay.

    Naa lang ko mga pangutana:

    Nagamit mo ug Document.InvokeScript(...) nya didto sa script nga gi-invoke nag tawag ug .NET exposed function? Remember nga ang GetContents nga method ginatawag sa javascript?

  11.    Advertisement

Page 3 of 6 FirstFirst 12345 ... LastLast

Similar Threads

 
  1. love can be expressed in various ways
    By Meganda in forum "Love is..."
    Replies: 6
    Last Post: 08-27-2012, 04:53 AM
  2. Replies: 36
    Last Post: 04-11-2011, 09:13 PM
  3. Bidding Script - Would it be Possible in istorya.net
    By salbahis in forum Support Center
    Replies: 1
    Last Post: 02-02-2009, 11:49 AM
  4. how can i prevent from being spied in yahoo messenger?
    By boyq in forum Networking & Internet
    Replies: 21
    Last Post: 06-06-2008, 12:42 PM
  5. Replies: 3
    Last Post: 01-14-2008, 04:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top