Scope of global property in WebApp

I developed a class for sending emails. My web-app for managing sport-clubs is a multi-client app (many sport-clubs) with muli-roles for each sport-club (trainer, administrator, player, …). One role may send mails to people belonging to other roles of its sport-club.

Each club shall have its own instance of the mailing-class with its own mailing parameters. The class is instantiated when a member of a sport-club logs in. If a mailing is performed, a thread uses the mailing object, a timer checks how many mails were sent and refreshes the result in a label.

By using a thread I can’t use a global session-property as mailing object because this would raise an error. So I declared a global property ‘vMail’ with Type ‘VereinMail’(my class for mailing). If a club logs in, the app instantiates vMail as new VereinMail and stores the parameter needed (username, SMTP-Server, password, mailadress) in regular properties of the object.

// In global module
Dim vMail as VereinMail

// Sport-Club logs in
Dim vMail As New VereinMail
vMail.SMTP="smtp.xyz.com"
vMail.Mailadress = "mickymouse@xyz.com"
...

Now my question: If more than one sport-club logs in simultaniously, will each club get its own mailing-object or will the object of the first club be globally accessible (which would not be wanted)?

Global properties in a module are shared for all users.
Better put the thread properly in session.

And you may put reference to session in a weak reference in your thread for use with websessioncontext object later to deliver answer.

[quote=392401:@Christian Schmitz]
And you may put reference to session in a weak reference in your thread for use with websessioncontext object later to deliver answer.[/quote]
Or just use a WebThread because it’ll keep track of which session it belongs to automatically.

Thanks Greg, that was the easiest solution for me :slight_smile: