CSharpTest.Net
Message Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Message Property

Glossary Item Box

The formatted string of the message or String.Empty if none

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Message As String
C# 
public string Message {get;}

Example

Log/Test/ThreadedLogTest.cs

C#Copy Code
Log.LogWrite += new LogEventHandler(Block_LogWrite);
try
{
    using (Log.Start("Blocking Test"))
    {
        //the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, false));

        //regaurdless, we should still get the first message
        EventData msg = NextMessage;
        Assert.AreEqual("Start Blocking Test", msg.Message);

        //Now let's just go nuts on the logger...
        for (int i = 0; i < 100; i++)
            Log.Write("Buffering at {0}%.", i);

        Thread.Sleep(100);
        Assert.AreEqual(0, _lastMessages.Count);
        _releaseBlock.Set();
        Thread.Sleep(100);
        Assert.IsFalse(_isBlocked.WaitOne(0, false));

        for (int i = 0; i < 100; i++)
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"));
    }
}
finally
{
    Log.LogWrite -= new LogEventHandler(Block_LogWrite);
}
VB.NETCopy Code
Log.LogWrite += New LogEventHandler(Block_LogWrite)
Try
    Using Log.Start("Blocking Test")
        'the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, False))

        'regaurdless, we should still get the first message
        Dim msg As EventData = NextMessage
        Assert.AreEqual("Start Blocking Test", msg.Message)

        'Now let's just go nuts on the logger...
        Dim i As Integer = 0
        While i < 100
            Log.Write("Buffering at {0}%.", i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Thread.Sleep(100)
        Assert.AreEqual(0, _lastMessages.Count)
        _releaseBlock.[Set]()
        Thread.Sleep(100)
        Assert.IsFalse(_isBlocked.WaitOne(0, False))

        Dim i As Integer = 0
        While i < 100
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
Finally
    Log.LogWrite -= New LogEventHandler(Block_LogWrite)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys