I have a class for HTTP transaction, and in some cases I want a little dialouge showing that its processing. I can get it working, but can't get it to refresh and change the text afterwards, i've tried a few things and just can't figure it out. It just stays at "Working..."
remember this is a CLASS not a form
I've put a msgbox in the ticker and it is ticking
remember this is a CLASS not a form
I've put a msgbox in the ticker and it is ticking
Code:
declared in the class...
Public WithEvents Working As Timer = New Timer
Dim WorkingDiag = New Windows.Forms.Form
Dim WorkingText = New Windows.Forms.Label
Function PostTo(ByVal URL As String, ByVal PostData As String, ByVal SupressWorking As Boolean)
If Not wc.Headers.Get("Content-Type") = "application/x-www-form-urlencoded" Then
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
End If
wc.Encoding = System.Text.Encoding.UTF8
If SupressWorking = False Then
WorkingText.Location = New Point(50, 8)
WorkingText.Size = New Size("160", "30")
WorkingText.Font = New Font("Arial", 12)
WorkingDiag.Size = New Size("160", "30")
WorkingDiag.StartPosition = FormStartPosition.CenterScreen
WorkingDiag.FormBorderStyle = FormBorderStyle.None
WorkingDiag.Controls.Add(WorkingText)
WorkingDiag.Show()
WorkingText.Text = "Working..."
WorkingDiag.Refresh()
Working.Interval = 800
Working.Start()
End If
Dim ReturnData = wc.UploadString(URL, PostData)
If SupressWorking = False Then
'WorkingDiag.Close()
End If
Return ReturnData
End Function
Sub WorkingTick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Working.Tick
If WorkingText.Text = "Working..." Then
WorkingText.Text = "Working"
WorkingDiag.Refresh()
End If
If WorkingText.Text = "Working" Then
WorkingText.Text = "Working."
WorkingDiag.Refresh()
End If
If WorkingText.Text = "Working." Then
WorkingText.Text = "Working.."
WorkingDiag.Refresh()
End If
If WorkingText.Text = "Working.." Then
WorkingText.Text = "Working..."
WorkingDiag.Refresh()
End If
End Sub