App Loading Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsgurdeep
    New Member
    • Apr 2007
    • 94

    App Loading Problem

    I am developing a mdi application for database handling on local network in my office using vb.net 2005 & sql 2005.

    All pc(s) are dual core 2 with 250GB Hard Disk & 3GB of RAM.

    It takes too much time to load.......
    & same as on opening an form on menu click.....
    My application stop responding when i try to load a crystal report.

    This problem is same on all pc(s).

    please tell me the cause & solution of this problem.
  • nukefusion
    Recognized Expert New Member
    • Mar 2008
    • 221

    #2
    Your request is too vague as the problem could really be absolutely anywhere within your code.

    If, as you say, it is slow when opening a form, or when loading a crystal report, I would start by looking in the constructor and load events for the form and the initialization of the offending report to try and track down where the bottleneck is.
    Maybe a code sample of these areas might help us to track down the problem.

    Comment

    • sashi
      Recognized Expert Top Contributor
      • Jun 2006
      • 1749

      #3
      Hi there,

      Check your code flow. Are you working with loops? Check you processor usage %

      Comment

      • MrShadow
        New Member
        • Dec 2008
        • 4

        #4
        G'Day,
        I found I have this problem when I'm loading data from the database when the form (or report) loads. You should probably try putting the database query into a different thread. That way, the form can continue loading without having to wait for the database query to complete.

        Hope this helps
        Cheers

        Comment

        • gsgurdeep
          New Member
          • Apr 2007
          • 94

          #5
          Now load events of all my forms are empty.

          an button click event is responcable for loading a report.

          Please tell Me the way of using any other process in second thread.

          Comment

          • gsgurdeep
            New Member
            • Apr 2007
            • 94

            #6
            Now load events of all my forms are empty.

            an button click event is responsible for loading a report.

            Please tell Me the way of using any other process in second thread.

            Comment

            • gsgurdeep
              New Member
              • Apr 2007
              • 94

              #7
              Load events of all my forms are empty, & a button click event is responsible for loading a report.
              Please tell Me the way (with any example) of using any other process in second thread.

              Comment

              • MrMancunian
                Recognized Expert Contributor
                • Jul 2008
                • 569

                #8
                Hi,

                First of all, try to avoid double (or triple) postings, as it is very confusing.

                There is a tool for checking your code and your workflow, called Ants Profiler. I think it's from Red Gate. Try using that program to find out what causes your program to run slowly.

                Steven

                Comment

                • MrShadow
                  New Member
                  • Dec 2008
                  • 4

                  #9
                  G'Day,
                  Actually, I've just realised that the code I use starts existing programs. It won't actually help you run code in a program. Anyway, in case you're interested below is some code that starts the Windows Event Viewer in a new thread. Multithreading does get rather tricky, especially when you need to pass messages around between threads and update controls on the form.

                  Code:
                  Dim prsViewer As New System.Diagnostics.Process
                          Try
                              prsViewer.EnableRaisingEvents = True
                              AddHandler prsViewer.Exited, AddressOf processExited
                              prsViewer.StartInfo.WorkingDirectory = "C:\Windows\System32\"
                              prsViewer.StartInfo.Arguments = "/s"
                              prsViewer.StartInfo.FileName = "eventvwr.msc"
                              prsViewer.Start()
                          Catch err As Exception
                              MessageBox.Show("There was an error starting the event viewer.  The error is:" & ControlChars.CrLf & err.ToString, "Error Loading Event Viewer", MessageBoxButtons.OK, MessageBoxIcon.Error)
                          End Try
                  To update controls on the form, you need a handler that can deal with threads. The code below is a quick example. First, you need to handle the finished thread.

                  Code:
                  Private Sub processExited(ByVal sender As Object, ByVal e As System.EventArgs)
                          Dim prsExited As System.Diagnostics.Process
                          prsExited = CType(sender, System.Diagnostics.Process)
                  
                  <Code to handle the finished thread>
                  End Sub
                  If you need to update the form in any way, you need this kind of routine:

                  Code:
                  Private Sub setListView(ByVal intItem As Integer, ByVal strStatus As String, ByVal strCode As String)
                          ' InvokeRequired required compares the thread ID of the
                          ' calling thread to the thread ID of the creating thread.
                          ' If these threads are different, it returns true.
                          If lstView.InvokeRequired Then
                              Dim d As New SetListViewCallback(AddressOf setListView)
                              Me.Invoke(d, New Object() {intItem, strStatus, strCode})
                          Else
                              lstView.Items(intItem).SubItems(2).Text = strStatus
                              lstView.Items(intItem).SubItems.Add(strCode)
                          End If
                      End Sub
                  As I said at the start, this code only starts existing programs on the PC, it doesn't run code in a different thread.

                  Cheers

                  Comment

                  Working...