locked
Several Questions about mutilthreading in VB.NET RRS feed

  • 問題

  • Hi

    I am working on a VB.Net Windows Application. I would need to implement a program that check database and process data.

    E.g. 2 processes. They would need to check in 2 different time frame.
    to check and process database every 15-20 seconds. and Process data to another database every 20 mins.

    I could do it without using Background worker.

    but during the process I would like the program return the status of the process.

    E.g. Each of the process would trigger several method, I would like the program display it on a label or something else.

    I knew that If I use background worker to do the mutilthreading, user can still use the GUI to do something else. so it could at least display a progress bar image to tell the user the program is doing something. Otherwise the program will look like it does not have response...etc

    In that situation, Shall I use 1 Background worker or 2 background worker as I have 2 progress.

    2) When the screen get updated will the background worker get stopped?
    I tried it once, like half years ago. I am not sure why when every I return a text on a label, the background process stopped. (It does not process any thing behind the method that update the label.)

    I would be grateful, if you could give me some advice how to program that application properly.


    Thanks in advance.

    2008年7月17日 10:32

解答

  •  

    1) From what you descript, I would suggest to use 2 background workers.

    2) We have to see the code block of what you have done on how the background worker to notice the UI program. Suppose that the background worker won't stop.

     

    2008年7月30日 2:27

所有回覆

  •  

    1) From what you descript, I would suggest to use 2 background workers.

    2) We have to see the code block of what you have done on how the background worker to notice the UI program. Suppose that the background worker won't stop.

     

    2008年7月30日 2:27
  • Hi Ken

    Thanks for your information.

    For the update UI question. I have solve it by setting WorkerReports Progress to true, and on ProgresChanges event
    I add the following code.
    Whenever I want to update the status
    I add a code to notify the bg_Workers progress event
    E.g.
    bg_Worker.ReportProgress(10, "NORMAL")

     Private Sub bg_Workers_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bg_Workers.ProgressChanged
            Select Case e.UserState.ToString.ToUpper
                Case "NORMAL"
                    lbl_Result.Text="Normal"

                Case "RUNBACKUP"
                    lbl_Result.Text="BackUp"

            End Select
        End Sub

    Please let me know if it is not a proper way to do it.

    Thanks a lot
    2008年7月30日 7:30