我有一个从数据库下载一些数据的按钮。我试图使这个按钮调用事件异步。
在按钮点击事件下,我正在调用异步方法
Public Delegate Function delAsyncMethodCaller()
**ButtonClick Method**
Dim obj As New delAsyncMethodCaller(AddressOf downloadReport)
Dim iAr As IAsyncResult = obj.BeginInvoke(New AsyncCallback(AddressOf AsyncComplete), Nothing)
Public Function downloadReport()
Dim objMargin As New clsOMACommon ---Getting Null Reference Exception
------Some Operation--------
End Function
Public Class clsOMACommon
Public strConn As String = Current.Application("ConnectionString").ToString.Trim --->The Current.Application is Nothing.
Public strDBOwner As String = Zurrent.Application("strDBOwner").ToString.Trim
------Some Operation------------
End Class
所以当我调用异步方法时,我在其中初始化一个对象,因为Current.Application是Nothing,我得到一个空引用异常。
我该如何解决这个问题?