OSDN Git Service

ネットワーク状態取得が例外出すことがあるので対応
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Wed, 11 May 2011 03:07:07 +0000 (12:07 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:19:29 +0000 (23:19 +0900)
Tween/MyCommon.vb
Tween/Tween.vb
Tween/Twitter.vb

index ed3e32a..50214b1 100644 (file)
@@ -30,6 +30,7 @@ Imports System.Reflection
 Imports System.Web
 Imports System.IO
 Imports System.Runtime.Serialization.Json
+Imports System.Net.NetworkInformation
 
 Public Module MyCommon
     Private ReadOnly LockObj As New Object
@@ -621,4 +622,12 @@ retry:
         End Using
         Return data
     End Function
+
+    Public Function IsNetworkAvailable() As Boolean
+        Try
+            Return NetworkInterface.GetIsNetworkAvailable
+        Catch ex As Exception
+            Return False
+        End Try
+    End Function
 End Module
\ No newline at end of file
index 06f421a..8a093c5 100644 (file)
@@ -2526,7 +2526,7 @@ Public Class TweenMain
     End Sub
     Private Sub GetTimeline(ByVal WkType As WORKERTYPE, ByVal fromPage As Integer, ByVal toPage As Integer, ByVal tabName As String)
 
-        If Not IsNetworkAvailable() Then Exit Sub
+        If Not Me.IsNetworkAvailable() Then Exit Sub
 
         '非同期実行引数設定
         Dim args As New GetWorkerArg
@@ -8233,11 +8233,7 @@ RETRY:
 
     Public Function IsNetworkAvailable() As Boolean
         Dim nw As Boolean = True
-        Try
-            nw = My.Computer.Network.IsAvailable
-        Catch ex As Exception
-            nw = False
-        End Try
+        nw = MyCommon.IsNetworkAvailable
         _myStatusOnline = nw
         Return nw
     End Function
@@ -8398,7 +8394,7 @@ RETRY:
 
         NotifyIcon1.Visible = True
 
-        If IsNetworkAvailable() Then
+        If Me.IsNetworkAvailable() Then
             GetTimeline(WORKERTYPE.BlockIds, 0, 0, "")
             If SettingDialog.StartupFollowers Then
                 GetTimeline(WORKERTYPE.Follower, 0, 0, "")
index a9b8867..209f4c6 100644 (file)
@@ -3218,7 +3218,7 @@ Public Class Twitter
             Dim sr As StreamReader = Nothing
             Do
                 Try
-                    If Not NetworkInterface.GetIsNetworkAvailable Then
+                    If Not MyCommon.IsNetworkAvailable() Then
                         Thread.Sleep(30 * 1000)
                         Continue Do
                     End If