Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 19th, 2005, 08:26 AM
Authorized User
Join Date: Jun 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multithreading and Synclock

I have a VB.Net assembly that is used in an ASP.Net C# app. I have a question about the target object of the SyncLock statement and multi-threading in general.

First question, if I have a Global object (a Public static object in Global.asax.cs) that is passed into a VB.Net Shared Function as a parameter, should the target object of SyncLock be a locally declared object, or a module level Shared object. Which of the below is the right thing to do?

Shared objSync As Object = New Object

Public Shared Sub DoSomethingElse(GlobalObject as Object)
    SyncLock (objSync)
    End SyncLock
End Sub


Public Shared Sub DoSomethingElse(GlobalObject as Object)
    Dim objSync As Object = New Object
    SyncLock (objSync)
    End SyncLock
End Sub

Second question, if I have two concurrent web page requests running in the same ASP.Net session would I need to do any syncronization in the methods (or class constructor) they call if they only called normal instance (Non-Shared) methods? The resource I want to protect in this example is a module level Protected object in the target class.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multithreading Help jenngarcia21 General .NET 0 March 9th, 2007 02:14 PM
multithreading in c# furqanms C# 0 November 21st, 2006 10:43 AM
regarding multithreading Mystic C# 1 July 22nd, 2006 12:44 AM
Multithreading question hexOffender Pro VB.NET 2002/2003 0 April 27th, 2006 03:37 PM
How to use Multithreading in VB6.0 ramk_1978 Beginning VB 6 3 January 24th, 2005 09:53 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.