locked
DoEvents() in asp.net RRS feed

  • Question

  • User-71648310 posted

    Hi,

     

    I am using ASP.NET and was wondering what i can use in replace of the DoEvents() in vb6?

    Hope you can help with this.

    If nothing is available, can you sugest ways I can get round this

     

    Thanks for your help

    Juzu

    Monday, May 23, 2005 11:08 AM

All replies

  • User-1630302068 posted
    im not sure what you mean by replacing DoEvents().  Do you have an algorithm that takes a long time to execute?  If so, i'd put that in some sort of 'loading' or 'processing' page.  Another method might be to use [*DANGER WILL ROBINSON DANGER*] threading to spin the operation off into another thread. 
    Tuesday, May 24, 2005 6:46 AM
  • User-343665941 posted

    Hi,

    Using System.threading;

             // C#'s version of DoEvents, will allow other threads to process including the system clock
            Thread.Sleep(0);

    Wednesday, January 13, 2010 4:22 AM
  • User-952121411 posted

    Well technically the DoEvents() in VB6 was a WinForms statement, because VB6 code was about making WinForms or similar type controls.  So there is an equivalent in .NET but it is in the 'System.Windows.Forms' namespace.  It is as follows:

    System.Windows.Forms.Application.DoEvents() 

    However, this is not going to help you so much in an ASP.NET application.  Since there is no response in a web app back to the client until the server is completely finished processing, you should not have to worry about secondary asynchronous requests.  Unless this is what you want.

    An example in VB6 how I used DoEvents() was to sort of free up the UI, so a 'Cancel' button or something of the sorts could be pressed and cancel a process.  In an ASP.NET application, you could launch an asynchronous process on the server to do some task, which would allow execution to continue and control to return to the client if that is what you want.

    Wednesday, January 13, 2010 9:17 AM
  • User-343665941 posted

    Yes you are correct in that

    doevents is vb

    and windows forms in .net does have application.doevents()

    However, when it comes to web applications in .net AND you wish to process a system Dependant variable ie ticks many time very quickly I have found using Thread.sleep(0) to help, by allowing the system to process other processes.

    Plus in an intensive operation, it is not a bad Idea to gracefully allow the system to do its job. (Although the system does have preemptive processing)

    :)

    application and OS working together for a quality customer journey

    Wednesday, January 13, 2010 4:25 PM
  • User-952121411 posted

    However, when it comes to web applications in .net AND you wish to process a system Dependant variable ie ticks many time very quickly I have found using Thread.sleep(0) to help, by allowing the system to process other processes.
     

    I don't disagree, but in the 7+ years I have been working with ASP.NET, I have not found it necessary in any process to call Thread.Sleep(0) for any system processing (that probably also indicates why DoEvent() is not available to any web namespace too).  Remember, the DoEvents() in VB6 was associated with a WinForms app that ran on the client, which included the client OS, multiple apps runnings, processes going etc., all dictated by the client.  That is a much different environment than a production web server.

    I would still like to hear the original poster's reasoning for wanting to use DoEvents() in an ASP.NET.  I am sure it will highlight the vast architectural differences between a VB6 WinForms app and an ASP.NET web app, and offer a more suitable solution.

    Thursday, January 14, 2010 10:55 AM