BeginInvoke and convert win app to web app

Last Reply 10 days ago By dharmendr

Posted 12 days ago

Hi

I have a windows form app which as my Boss orders I need to convert it to Asp.net Web form : 

More about my project: 

when I click on run button, my project runs and it caculates some data and it shows results in some textboxes till it finished . At the End the button save data enabled in order to save Results:

hier is the functions:

Run Button:

Me.Run.Enabled = False
        Me.Run.Text = "Please wait ..."

        Me.simphony.Enabled = False
        Me.access.Enabled = False

        Me.optimizationEngineField = New OptimizationEngine(economyImportance:=0.5,
                                                            simphonyAnalysisModel:=Me.simphonyAnalysisEngine)

        Dim tempThread As New Threading.Thread(Sub()
                                                   Me.bestSolutionField = Me.optimizationEngineField.StartOptimization(percentErrorTermination:=True,
                                                                                                                       maxIteration:=CInt(Me.TextBoxMaxIteration.Text),
                                                                                                                       percentError:=CDbl(Me.TextBoxAccuracy.Text))
                                               End Sub)
        tempThread.Start()
        Me.TextBoxAccuracy.Enabled = False
        Me.TextBoxMaxIteration.Enabled = False

        Me.OptimizationStatusUpdate()

Optimization:

 

  Private Sub OptimizationStatusUpdate()
        Dim tempThread As New Threading.Thread(Sub()
                                                   Dim attempt As Integer = 0

                                                   Dim firstRun As Boolean = True
                                                   While True
                                                       If Me.optimizationEngineField.IsRunning Then
                                                           firstRun = False
                                                           Me.BeginInvoke(Sub()
                                                                              Me.TextBoxStatus.Text = Me.optimizationEngineField.Status
                                                                              Me.TextBoxIsRunning.Text = Me.optimizationEngineField.IsRunning
                                                                              Me.TextBoxIterationNumber.Text = Me.optimizationEngineField.IterationNumber
                                                                              Me.TextBoxPercentError.Text = Me.optimizationEngineField.PercentError
                                                                              Me.TextBoxActiveAntCount.Text = Me.optimizationEngineField.ActiveAntCount
                                                                              Me.TextBoxAggregatedAntCount.Text = Me.optimizationEngineField.aggregatedAntCount
                                                                          End Sub)


                                                       Else
                                                           If Not Me.optimizationEngineField.IsRunning And firstRun = False Then
                                                               attempt = attempt + 1
                                                           End If
                                                           If attempt >= 5 Then
                                                               Exit While
                                                           End If
                                                       End If
                                                       Threading.Thread.Sleep(1000)
                                                   End While
                                                   Me.BeginInvoke(Sub()
                                                                      Me.ButtonSaveResults.Text = "Save Results"
                                                                      Me.ButtonSaveResults.Enabled = True
                                                                      Me.TextBoxIsRunning.Text = "False"
                                                                      Me.Run.Enabled = True
                                                                      Me.Run.Text = "Run"

                                                                      Me.simphony.Enabled = True
                                                                      Me.access.Enabled = True
                                                                  End Sub)

                                               End Sub)
        tempThread.Start()
    End Sub

#1)how convert BeginInvoke into web asp.net?

#2) Do you hav an easier way to perform?

Thanks

 

PS: How my project works:

How my project works

You are viewing reply posted by: dharmendr 10 days ago.