PowerTCP Mail for .NET
Busy Property
See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Smtp Class : Busy Property




Returns true if a method is currently in use.

Syntax

Visual Basic (Declaration) 
<BrowsableAttribute(False)>
Public ReadOnly Property Busy As Boolean
Visual Basic (Usage)Copy Code
Dim instance As Smtp
Dim value As Boolean
 
value = instance.Busy
C# 
[BrowsableAttribute(false)]
public bool Busy {get;}
Managed Extensions for C++ 
[BrowsableAttribute(false)]
public: __property bool get_Busy();
C++/CLI 
[BrowsableAttribute(false)]
public:
property bool Busy {
   bool get();
}

Property Value

true if a method is currently is use, otherwise false

Example

The following example demonstrates using the BusyChanged event to see if the socket is busy.
Visual BasicCopy Code
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.

Private Sub BusyTest()
   ' Do something to cause the Busy event to be raised
        
   ' Create a message
   Dim msg As New MessageStream()
   msg.To.Add(New MailAddress("you@test.com"))
   msg.From = New MailAddress("me@test.com")
   msg.Subject = "test"
   msg.Attachments.Add("C:\test\test.bmp")

   Smtp1.Server = "mail.test.com"
   Smtp1.Send(msg)
End Sub

Private Sub Smtp1_BusyChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Smtp1.BusyChanged
   If Smtp1.Busy Then
      label1.Text = "Socket is busy"
   Else
      label1.Text = "Socket is not busy"
   End If
End Sub
C#Copy Code
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.

private void BusyTest()
{
   // Do something to cause the Busy event to be raised

   // Create a message
   MessageStream msg = new MessageStream();
   msg.To.Add(new MailAddress("you@test.com"));
   msg.From = new MailAddress("me@test.com");
   msg.Subject = "test";
   msg.Attachments.Add("C:\\test\\test.bmp");
   
   smtp1.Server = "mail.test.com";
   smtp1.Send(msg);
}

private void smtp1_BusyChanged(object sender, System.EventArgs e)
{
   // Check the Busy Property
   if(smtp1.Busy)
      label1.Text = "Socket is busy";
   else
      label1.Text = "Socket is not busy";
}

Remarks

When used in PowerTCP Zip Compression for .NET, this property provides protection against accessing a method that is still processing a command.

When used in an Internet communications component, this property provides protection against sending commands over a busy socket. For example, if the PowerTCP component is engaged in sending or receiving data, and another method is called that requires use of the same socket, a BusyException is thrown.

The Object.BusyChanged event is raised whenever the value of this property changes.

For Internet communications components, check this property within your code if you feel a new operation could be attempted over a socket that is already engaged in sending or receiving data. This property is also useful for displaying socket status to the user. For example, a "stoplight" could be part of the user interface that would be red when the Object.Busy property is true, and green when false.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.