Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Downloads
.NET 2.0
.NET 1.*
.NET x64
VC++ 6.0
VC++ 7.0
VC++ 8.0
Java
Ruby
Perl 5.8.*
Perl 5.10.*
Python
Bounce ActiveX
Charset ActiveX
Email ActiveX
FTP2 ActiveX
Crypt ActiveX
HTML-to-XML ActiveX
HTTP ActiveX
IMAP ActiveX
MHT ActiveX
MIME ActiveX
RSA ActiveX
Socket ActiveX
Spider ActiveX (free)
String ActiveX (free)
Tar ActiveX
Upload ActiveX (free)
XML ActiveX (free)
XMP ActiveX
Zip ActiveX

Index of Chilkat Blog Posts

February 11, 2008

Prevent VB.NET User-Interface from Freezing

To prevent the user-interface from freezing, your application needs to call Application.DoEvents periodically while a time-consuming operation is in progress. The HeartbeatMs property is common to all Chilkat classes with events, and it controls the interval between AbortCheck callbacks. The AbortCheck callback provides (1) an opportunity for the application to call DoEvents, and (2) an opportunity for the application to abort the operation in progress.

This example demonstrates HeartbeatMs and AbortCheck in VB.NET for sending email:

	
    Dim WithEvents m_mailman As Chilkat.MailMan
	
    Dim m_abort As Boolean
	
    ' Call Application.DoEvents to keep the user-interface from "freezing".
    Private Sub m_mailman_OnAbortCheck(ByVal sender As Object, ByVal args As Chilkat.AbortCheckEventArgs) Handles m_mailman.OnAbortCheck
        Application.DoEvents()
	
        ' If the abort button was pressed, set the abort flag:
        If (m_abort) Then
            args.Abort = True
        End If
    End Sub
	
    Private Sub m_mailman_OnSendPercentDone(ByVal sender As Object, ByVal args As Chilkat.MailPercentDoneEventArgs) Handles m_mailman.OnSendPercentDone
        ProgressBar1.Value = args.PercentDone
	
        ' If the abort button was pressed, set the abort flag:
        If (m_abort) Then
            args.Abort = True
        End If
    End Sub
	
    Private Sub btnAbort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbort.Click
        m_abort = True
    End Sub
	
    Private Sub SendEmailWithProgress()
	
        m_mailman = New Chilkat.MailMan()
	
        Dim success As Boolean
	
        success = m_mailman.UnlockComponent("Anything for 30-day trial")
        If (Not success) Then
            MessageBox.Show("Failed to unlock email component")
            Exit Sub
        End If
	
        ' Make sure to enable events:
        m_mailman.EnableEvents = True
	
        ' Set the HeartbeatMs property so that AbortCheck events are periodically received
        ' every 100 milliSec:
        m_mailman.HeartbeatMs = 100
	
        m_mailman.SmtpHost = "mail.chilkatsoft.com"
        m_mailman.SmtpUsername = "myLogin"
        m_mailman.SmtpPassword = "myPassword"
	
        Dim email As New Chilkat.Email()
        email.Subject = "This is a test"
        email.Body = "This is a test"
	
        email.From = "support@chilkatsoft.com"
        email.AddTo("Chilkat Admin", "admin@chilkatsoft.com")
	
        ' Before sending, give focus to our "Abort" button in the user interface.
        ' If focus is not given, it requires two clicks to abort -- the first
        ' click gives the button focus, the 2nd click first the "button click" event.
        btnAbort.Focus()
        m_abort = False
	
        success = m_mailman.SendEmail(email)
        MessageBox.Show(m_mailman.LastErrorText)
	
    End Sub


Privacy Statement. Copyright 2000-2008 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, and Windows 95/98/NT4.