.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Educational question: How server objects are accessed from multiple client threads?

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
I will appreciate it if someone can help me to undestand how the following scenario works:   There is remoting server that is registered as WellKnownObjectMode.Singleton. Server implementation: It instantiates a class TestServer that implements interface IFoo interface IFoo { IHelper GetHelper() }   interface IHelper { void StoreString(); }   Implementation of TestServer: internal sealed class TestServer: System.MarshalByRefObject, IFoo { private IHelper> helper = new Helper(); public IHelper GetHelper(string helper){return helper;} }   Implementation of Helper: internal sealed class Helper : System.MarshalByRefObject, IHelper { public void StoreString (string val) {}; }   Implementation of a client (simplified; shown to illustrate the question only): static class Program { public static IFoo TestService; public static IHelper Helper; public TestThreads testmultiplecalls; [STAThread] static void Main() { TestService = (IFoo)Activator.GetObject(typeof(IFoo),"ipc://Channel"); Helper = TestService.GetHelper(); testmultiplecalls.Start(); } }   internal class TestThreads { public Start() { for (int i = 0; i < 20; i++) ThreadPool.QueueUserWorkItem((new TestCall(i.ToString())).DoWork); } }     internal class TestCall { private string m_str; public TestCall (string str) {m_str = str;} public void DoWork() { Program.Helper.StoreString(m_str); } }     Que

View Complete Post

More Related Resource Links

Client image files uploaded to Server are staying locked when accessed again.


I have a web form that, upon user request, uploads an image file from the client to a server folder, makes a thumbnail and saves to another folder than sets an imageurl of an image control to that thumbnail. All fine up to here, problem is that at times (not always but could not find the exact pattern) when uploading an existing file, it throws a ' ... file used by another process ... ' error, both on the original image file and the created thumbnail. Is there a way to prevent the locking of these files or alternately, which object need I destroy to release the image file and avoid these contentions? I do destroy the image object immediately after thumbnail is created. Ideas anyone?

WCF Callback - multiple Client Multiple Server

Its easy fro one server with multple clients registering their callback address to single server. What i want to use multiple server to have clients callbacks address shared among all servers. because we are using load balancing server, we dont know which server will reposnse to request. Kindly tell me any solution for this

Multiple Paramatized Threads



I have a  method that calls two subsequent methods that contain multiple parameters. I would like to run these methods simultaneously and then preform an action based on the return of both methods, so The parent thread cannot continue until BOTH threads have completed. I have tried going trough MSDN examples and haven't got anything to work (the issue is that the parent thread (aka the main method) continues on once one of the thread completes). I have tried cheking the state of threads and waiting the threads, but have not gotten anywhere. Any help would be great. Thanks.

Data Points: SQL Server Management Objects


SQL Server Management Objects offer developers a robust toolset for backing up and restoring databases, and issuing DDL commands, as John Papa explains.

John Papa

MSDN Magazine June 2007

ClickOnce: Deploy and Update Your Smart Client Projects Using a Central Server


ClickOnce is a new deployment technology that allows users to download and execute Windows-based client applications over the Web, a network share, or from a local disk. Users get the rich interactive and stateful experience of Windows Forms, but still have the ease of deployment and updates available to Web applications. ClickOnce applications can be run offline and support a variety of automatic and manual update scenarios.Learn all about it here.

Brian Noyes

MSDN Magazine May 2004

ASP.NET Pipeline: Use Threads and Build Asynchronous Handlers in Your Server-Side Web Code


Fortunately for developers, threading in ASP.NET is a lot easier than it was in ASP. In this article, the author takes a look at threading in the ASP.NET HTTP pipeline, and explains how threads are managed efficiently without the involvement of the developer. The article considers how the common language runtime threadpool is used by ASP.NET to service requests, looks at the pooling mechanisms used for handlers, modules, and applications, and covers both IIS 5.0 and IIS 6.0 and how they differ in their approach to request processing and thread allocation. Finally, how and when to use asynchronous handlers is discussed for developers who still need to use threads in their own applications.

Fritz Onion

MSDN Magazine June 2003

Windows Forms: Give Your .NET-based Application a Fast and Responsive UI with Multiple Threads


If your application performs any non-UI processing on the thread that controls the user interface, it may make the app seem slow and sluggish, frustrating users. But writing multithreaded apps for Windows has long been restricted to C++ developers. Now with the .NET Framework, you can take advantage of multiple threads in C# to control the flow of instructions in your programs and isolate the UI thread for a fast and snappy user interface. This article shows you how. Also, it discusses the pitfalls of multiple threads and presents a framework for safe concurrent thread execution.

Ian Griffiths

MSDN Magazine February 2003

SOAP: Using ATL Server to Build an Asynchronous SOAP Client in Unmanaged C++


SOAP opens up a new world of Web Services, letting you make function calls across a network or the Internet. But this flexibility creates new problems when your app needs to wait for calls to return from halfway around the world. What you need is an asynchronous SOAP client that takes advantage of threading to continue execution while waiting for calls over the wire. This article covers the basics of building such a client with ATL.

Pranish Kumar and Bogdan Crivat

MSDN Magazine April 2002

SQL Server and DMO: Distributed Management Objects Enable Easy Task Automation


SQL Server can be administered programmatically using system stored procedures, but Distributed Management Objects (DMO) offer a more modern, object-oriented alternative. This article introduces SQL-DMO in SQL Server 7.0 and SQL Server 2000 and describes the SQL-DMO object model, then focuses primarily on the Databases tree and the JobServer tree of the object model. The sample code and the article show how to use various objects such as the Registry object, the Configuration object, and the Database object to automate common administration tasks such as programmatically retrieving configuration settings, creating new databases, applying T-SQL scripts, and creating and scheduling backups.

Francesco Balena

MSDN Magazine May 2001

RPC and C++: Build a Template Library for Distributed Objects Containing Multiple Interfaces


Building a C++ template library for developing distributed object-oriented applications using Remote Procedure Calls (RPC) allows the programmer to design RPC applications that are composed of components that implement multiple interfaces. This article demonstrates the use of techniques such as assembly-level thunks to build machine code on the fly, and C++ features such as templates, conversion operators, virtual destructors and virtual function tables. Along the way, familiar C++ interfaces and classes are transformed into a distributed application. The benefits of using distributed objects rather than raw remote procedures, which include writing fewer lines of code, is explained.

Ajai Shankar

MSDN Magazine November 2000

Using Server-Side XSL for Early Rendering: Generating Frequently Accessed Data-Driven Web Pages in A


Dynamic data-driven pages have become the basis of many cutting-edge Web sites. Early render systems can provide better performance and maintainability for data-driven Web sites by generating frequently accessed pages that contain less-volatile information ahead of time. We'll show you an example of a server-side solution that uses Extensible Stylesheet Language (XSL) to merge data and layout information into HTML that is compatible with just about any modern Web browser. Using these techniques to render Web pages early can reduce the load on your database back end and increase performance for your users.

Paul Enfield

MSDN Magazine April 2000

Client ID basic question


Hi guys,

Is there any problem to use MANUALLY, within a Javascript, the client ID code?

Like that  ctl00_ContentPlaceHolderConteudo_pgtoiframe


I have one iFrame that need to access div style located in the parent page. So I've done that using manually the clientID code. The code works perfectly and It's still working fine right now.

Will I get errors or problems in the future using it in that manner????

Thank you


passing object values from server to client problem


I get a message that x_login is not declared.  I added Dim login as String = "123", but that didn't help.  What's the problem?

code behind....

Dim Login = "123"
x_login.Value = loginID


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="simForm" runat="server" method='post' action='https://test.authorize.net/gateway/transact.dll'>
        <input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
        <input type='hidden' runat="server" name='x_login' id='x_login' />
        <input type='submit' runat="server" id='buttonLabel' />



Using SQL Server 2008 R2 client with Enterprise Library



I am modifying an existing application that uses SQL Server 2008 as the database and Enterprise Library 4.1 for Data Access .

What I need to do is to make it use the SQL Server 2008 R2 client to take advantage of out of the box failover capabilities.

Any idea how I can accomplish this?


server to communicate with multiple clients

Hi, The server sends event to multiple clients; It goes through a list of callback destination clients and sends one by one. My question is, if one client down or in dead loop processing the event, does it affect all the other clients to receive event? Is it the same if I use HTTP or name pipe? The code is like that: for each (callback^ cb in registeredCallbacks) { cbClient = getClient(cb); if (cbClient) { try { cbClient->sendEvent(data); } catch (Exception^ ex) { deregisterCallback(cb, ex) } }   I wonder if one client fails, would it affect all the others. Thanks in advance Simon

clr assembly in sql server - working directory? and exception question

Hello, I have a small assembly in sql server 2008... it's pretty simple, but in the very rare circumstance that it may throw an exception I am catching it and writting to a log file. something like: using (StreamWriter sr = new StreamWriter(@".\ErrorLog.txt", true)) { sr.WriteLine("{0:G} ===> {1}", DateTime.Now, ex.Message); } I believe that should write the file to the working directory... 1. what would the working directory be for sql server 2008? the binn directory? 2. what would happen if a clr assembly added to sql server throws an exception that is not handled by your clr code?

Error 2908 while installing sql server 2005 management objects collection on Win 7

I have SQL Server native client 2005 installed on Win 7 64-bit machine. While installing SQL Server XMO 2005 it gives error 2908 and aborts installation. Any suggestion on the error?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend