@@ -178,15 +178,20 @@ Public Class Form1
178178 Return Nothing
179179 End Function
180180
181- Private Function getGithubReleases() As Dictionary( Of String , String )
181+ Private Async Function getGithubReleases() As Task( Of Dictionary( Of String , String ) )
182182 Dim result As New Dictionary( Of String , String )
183183 Dim apiUrl As String = "https://api.github.com/repos/InterfaceGUI/QuickIPchange/releases/latest"
184184 Dim responseJson As String
185185
186186 Using wc As New WebClient()
187187 ' 設置 User-Agent,GitHub API 需要這個 header
188188 wc.Headers.Add( "User-Agent" , "request" )
189- responseJson = wc.DownloadString(apiUrl)
189+ Try
190+ responseJson = Await wc.DownloadStringTaskAsync(apiUrl)
191+ Catch ex As Exception
192+ Return Nothing
193+ End Try
194+ 'responseJson = wc.DownloadString(apiUrl)
190195 End Using
191196
192197 Dim jsonObject As JObject = JObject.Parse(responseJson)
@@ -207,6 +212,7 @@ Public Class Form1
207212 result.Add( "tag_name" , tagName)
208213 result.Add( "exe_download_url" , exeDownloadUrl)
209214 result.Add( "release_notes" , jsonObject( "body" ).ToString())
215+ ToolStripStatusLabel7.Visible = True
210216 Return result
211217
212218
@@ -216,10 +222,15 @@ Public Class Form1
216222
217223 End Sub
218224
219- Private Sub Timer2_Tick(sender As Object , e As EventArgs) Handles Timer2.Tick
225+ Private Async Sub Timer2_Tick(sender As Object , e As EventArgs) Handles Timer2.Tick
220226 Timer2.Enabled = False
221227
222- Dim ReleasesInfo As Dictionary( Of String , String ) = getGithubReleases()
228+ Dim ReleasesInfo As Dictionary( Of String , String ) = Await getGithubReleases()
229+ If ReleasesInfo Is Nothing Then
230+ ToolStripStatusLabel7.Visible = True
231+ Exit Sub
232+ End If
233+
223234 Dim latestVersion As Version = New Version(ReleasesInfo.Item( "tag_name" ))
224235 Dim currentVersion As Version = Assembly .GetExecutingAssembly().GetName().Version
225236
@@ -235,6 +246,7 @@ Public Class Form1
235246 End If
236247
237248 ElseIf comparisonResult = 0 Then
249+ ToolStripStatusLabel6.Text = $"已是最新版本"
238250 Console.WriteLine( $"目前版本 {currentVersion} 已是最新版本" )
239251 Else
240252 Console.WriteLine( $"目前版本 {currentVersion} 高於 GitHub 上的版本 {latestVersion}" )
0 commit comments