VB.NET中回調(diào)函數(shù)如何使用

VB.NET中回調(diào)函數(shù)如何使用,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

成都創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供神農(nóng)架林區(qū)網(wǎng)站建設(shè)、神農(nóng)架林區(qū)做網(wǎng)站、神農(nóng)架林區(qū)網(wǎng)站設(shè)計(jì)、神農(nóng)架林區(qū)網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、神農(nóng)架林區(qū)企業(yè)網(wǎng)站模板建站服務(wù),十多年神農(nóng)架林區(qū)做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

VB.NET經(jīng)過長時(shí)間的發(fā)展,很多用戶都很了解VB.NET回調(diào)函數(shù)了,這里我發(fā)表一下個(gè)人理解,和大家討論討論。創(chuàng)建數(shù)據(jù)庫事件處理函數(shù)(VB.NET回調(diào)函數(shù))

無論什么時(shí)候一個(gè)對(duì)象被打開并要被修改時(shí),數(shù)據(jù)庫事件處理函數(shù)會(huì)被調(diào)用。當(dāng)然,如果這時(shí)我們監(jiān)視的命令不是活動(dòng)的,我們就應(yīng)該跳過任何被這個(gè)VB.NET回調(diào)函數(shù)調(diào)用的內(nèi)容。

If bEditCommand = False Then
Return
End If

同樣地,如果我們監(jiān)視的命令已經(jīng)結(jié)束,而ObjectOpenedForModify事件被另一個(gè)VB.NET回調(diào)函數(shù)再次觸發(fā)的話,而這時(shí)有對(duì)象被修改時(shí),我們要阻止所有由這個(gè)VB.NET回調(diào)函數(shù)執(zhí)行的動(dòng)作。

If bDoRepositioning = True Then
Return
End If

這個(gè)VB.NET回調(diào)函數(shù)剩余部分的代碼用來驗(yàn)證我們是否正在處理EMPLOYEE塊索引。如果是的話,我們就獲取它的ObjectID和位置(三維點(diǎn))。下面的代碼可以被粘貼到這個(gè)事件處理函數(shù)函數(shù)。

Public Sub objOpenedForMod(ByVal o As Object, ByVal e As ObjectEventArgs)  If bEditCommand = False Then  Return  End If  If bDoRepositioning = True Then  Return  End If  Dim objId As ObjectId  objId = e.DBObject.ObjectId  Dim trans As Transaction  Dim bt As BlockTable  Dim db As Database  db = HostApplicationServices.WorkingDatabase  trans = db.TransactionManager.StartTransaction()  Try  'Use it to open the current object!  Dim ent As Entity = trans.GetObject(objId, OpenMode.ForRead, False)  If TypeOf ent Is BlockReference Then 'We use .NET's RTTI to establish type.  Dim br As BlockReference = CType(ent, BlockReference)  'Test whether it is an employee block  'open its extension dictionary  If br.ExtensionDictionary().IsValid Then  Dim brExtDict As DBDictionary = trans.GetObject(br.ExtensionDictionary(), OpenMode.ForRead)  If brExtDict.GetAt("EmployeeData").IsValid Then  'successfully got "EmployeeData" so br is employee block ref  'Store the objectID and the position  changedObjects.Add(objId)  employeePositions.Add(br.Position)  'Get the attribute references,if any  Dim atts As AttributeCollection  atts = br.AttributeCollection  If atts.Count > 0 Then  Dim attId As ObjectId  For Each attId In atts  Dim att As AttributeReference  att = trans.GetObject(attId, OpenMode.ForRead, False)  changedObjects.Add(attId)  employeePositions.Add(att.Position)  Next  End If  End If  End If  End If  trans.Commit()  Finally  trans.Dispose()  End Try  End Sub

看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。

分享文章:VB.NET中回調(diào)函數(shù)如何使用
本文路徑:http://bm7419.com/article22/ipdscc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、、響應(yīng)式網(wǎng)站、面包屑導(dǎo)航、外貿(mào)網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司