Asp.Net Threading Issue.


I have a mailer program for which has been working fine, until I added this:

Dim myThread as New Threading.Thread(AddressOf SendMessages)

Sometimes my page works, sometimes I get this pop up in my Visual Studio:

An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in Unknown Module.

Additional information: The type System.Web.HttpException in Assembly System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not marked as serializable.

This never happened until I started running the SendMessages sub on a seperate thread.

Any ideas?
Who is Participating?
Bob LearnedConnect With a Mentor Commented:
What was the original reason for wanting threading?  It can be a complex operation, even though it seems simple at first.

Here is some information that may prove to be useful for multi-threaded applications:

Introduction to making multithreaded VB.NET Apps:

Sub IncrementWebCount()
    SyncLock objMyLock
        intWebHits += 1
    End SyncLock
End Sub

From help:
A SyncLock statement allows statements to be synchronized on an expression, which ensures that multiple threads of execution do not execute the same statements at the same time.

This is called the "critical section"

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.