水如烟

                 顺其自然,水到渠成 LzmTW

文或代码皆是面向初学者.我是爱好者,也是初学者.那些"文章",只按自己理解写,我是不知术语名词的.所以只供参考,也仅供参考.

导航

异类HOW TO:适时弹出指示框(七)

Posted on 2006-05-30 12:17  水如烟(LzmTW)  阅读(332)  评论(0编辑  收藏  举报
测试类:
Imports LzmTW.ApplicationBase
Imports LzmTW.uRemoting.MethodWatcher

<MethodLog()> <MethodLogAppend("Add")> <MethodLogAppend("LinkDatabase")> _
<MessageForm()> _
<MessageFormAppend("Add", _
Message:
="正处理Add若你原耐心等多一天,定会令历史因些改", title:="请稍候,就五分钟也等不来吗", _
Formtype:
=MessageFormType.Progress)> _
<MessageFormAppend("LinkDatabase", _
Message:
="正尝试连接数据库 ." & vbCrLf & "你不用说我也知道,可我也骗我自己,说你没骗我", title:="稍等,骗人的,数据库在哪?", _
Formtype:
=MessageFormType.Progress)> _
Public Class MethodWatcherTestClass
    
Inherits ContextBoundObject


    
Public Function Add(ByVal x As IntegerByVal y As IntegerAs Integer
        
'LzmTW.ApplicationBase.WaitingForm.DefaultForm.Show()
        For i As Integer = 0 To 2000
            
' LzmTW.ApplicationBase.WaitingForm.DefaultForm.ReceiveMessage("正在处理第{0}项", New Object() {i})
            Threading.Thread.Sleep(1)
        
Next
        
' LzmTW.ApplicationBase.WaitingForm.DefaultForm.Close()
        Return x + y
    
End Function

    
Public Sub LinkDatabase(ByVal t As StringByVal b As String)
        
For i As Integer = 0 To 2000
            
'Console.WriteLine(i)
            Threading.Thread.Sleep(1)
        
Next
    
End Sub

End Class

测试代码:
Public Class Form1

    
Dim t As New MethodWatcherTestClass
    
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        t.Add(
1001)
        t.LinkDatabase(
"it""is")
    
End Sub

    
Dim MethodLogCenter As New LzmTW.uRemoting.MethodWatcher.MethodLogCenter

    
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MethodLogCenter.Ready()
    
End Sub

    
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MethodLogCenter.Remove()
    
End Sub

    
Private Sub testThread()
        t.Add(
11)
        t.LinkDatabase(
"it""is")
    
End Sub
End Class

图示如前文所示,输出日志为:

WaitingDemo.MethodWatcherTestClass+Add(100,1)
MethodOtherBeing:WaitingDemo.MethodWatcherTestClass+Add:MessageFormAppendAttribute
MethodOtherOver:WaitingDemo.MethodWatcherTestClass+Add:MessageFormAppendAttribute
WaitingDemo.MethodWatcherTestClass+Add Result is 101
WaitingDemo.MethodWatcherTestClass+LinkDatabase(it,is)
MethodOtherBeing:WaitingDemo.MethodWatcherTestClass+LinkDatabase:MessageFormAppendAttribute
MethodOtherOver:WaitingDemo.MethodWatcherTestClass+LinkDatabase:MessageFormAppendAttribute
WaitingDemo.MethodWatcherTestClass+LinkDatabase Result is System.Void