1
我做了一個應用程序,我們公司用來啓動數據庫並在需要時在用戶機器上更新它們。緩慢應用程序的進程啓動和錯誤
在啓動數據庫和數據庫啓動緩慢時,我遇到了一些小問題。當發生這種情況時,我的應用程序會拋出一個異常,因爲我假設它正在等待某種迴應。
截至目前拋出的錯誤是:系統找不到指定的文件
我試圖以防止這樣的情況下,這種異常日誌記錄(慢速應用程序),但仍允許伐木如果一個真正的打開數據庫時發生錯誤。
目前代碼我使用:
Private Sub OpenApplication()
If File.Exists(LocalPathString) Then ' File Found. Open the File.
Try
Dim ps As New Process
ps = Process.Start(LocalPathString)
Catch ex As Exception
ex.Source += " | " & LocalPathString
RaiseEvent ShowError(ex)
Finally
RaiseEvent CancelIt() ' Thread Complete. Close the ActionForm
End Try
Else
If LocalPathString = vbNullString Then
RaiseEvent CancelIt() ' No file exits. Cancel thread.
Else
RaiseEvent ShowError(New Exception("Database Not Located: " & LocalPathString))
End If
End If
End Sub
堆棧跟蹤:
System.Diagnostics.Process.StartWithShellExecuteEx(startInfo As ProcessStartInfo)
App.exe: N 00912
System.Diagnostics.Process.Start()
App.exe: N 00136
System.Diagnostics.Process.Start(startInfo As ProcessStartInfo)
App.exe: N 00049
SAMi.ActionClass.OpenApplication()
App.exe: N 00117
我想過這個,但並不想打折拋出相同信息但不是出於同樣原因的真實錯誤。 – famousKaneis
您也可以匹配異常類型來確保。 –
畢竟,我最終採用這種方法,謝謝。 – famousKaneis