Thats correct! It works in my solution, since the use case is to start a
batch like process that doesn´t happen to often...and let the user proceed
to other tasks..
I think that you should try using the threadpool and test the performance...
/Oscar
"JV" <oyeahright@spammenot.com> wrote in message
news:OKeURMrRGHA.4952@TK2MSFTNGP09.phx.gbl...[color=blue]
> I've only skimmed over your code thus far, but it appears you are spawning
> a thread from the threadpool for each ASP.NET request? If I'm correct
> about that, that would become a scalability issue.
> My goal is to have a single worker thread that manages the dataset and
> multiple requests putting/getting data. Wish I could have just used
> MSSQL for this.
>
>
> "Oscar Thornell" <nospam@internet.com> wrote in message
> news:ecOcw4qRGHA.4956@TK2MSFTNGP09.phx.gbl...[color=green]
>> Hi,
>>
>> Check this out...
>>
>> /Oscar
>>
>> //Buisness layer...gets called from an ASP.NET web page...
>> public bool InitAsyncOperation(string someData)
>> {
>> try
>> {
>> //Access layer
>> Access access = Access.GetInstance(CurrentUser);
>>
>> if(access.IsRunning)
>> {
>> return false;
>> }
>> else
>> {
>> //First we do some sync operation...
>> Wrapper wrapper = access.Validate(someData);
>>
>> //Then we kick of the async...
>> MyDelegate d = new MyDelegate(<Another method...that performs the
>> async operation...>);
>> AsyncHelper.Execute(d, wrapper);
>> }
>> }
>> catch(Exception ex)
>> {
>> if(ExceptionPolicy.HandleException(ex, CONTROLLER_EXCEPTION_POLICY))
>> throw;
>> }
>>
>> return true;
>> }
>>
>>
>>
>>
>> ///Class AsyncHelper
>> using System;
>> using System.Reflection;
>> using System.Threading;
>>
>> namespace <SomeCompany>.<SomeApp>.Util
>> {
>> /// <summary>
>> /// Starting with the 1.1 release of the .NET Framework, the SDK docs
>> /// now carry a caution that mandates calling EndInvoke on delegates
>> /// you've called BeginInvoke on in order to avoid potential leaks.
>> /// This means you cannot simply "fire-and-forget" a call to
>> BeginInvoke
>> /// when spawning a new worker thread from the thread pool without the
>> risk
>> /// of creating a memory leak.
>> ///
>> /// The usage model is that instead of calling BeginInvoke against a
>> delegate,
>> /// you would instead call AsyncHelper.Execute, passing that delegate and
>> it's parameters as input.
>> /// See:
http://staff.develop.com/woodring for further information.
>> /// </summary>
>> /// <example>
>> /// delegate void CalcAndDisplaySumDelegate( int a, int b );
>> /// CalcAndDisplaySumDelegate d = new
>> CalcAndDisplaySumDelegate(someCalc.Add);
>> /// AsyncHelper.Execute(d, 2, 3);
>> /// </example>
>> public class AsyncHelper
>> {
>> private static WaitCallback callback = new
>> WaitCallback(DynamicInvokeShim);
>>
>> /// <summary>
>> /// Takes a delegate and a list of arguments. Performs asynchronous
>> invocation of the
>> /// target(the Class.Method the delegates points to..).
>> /// </summary>
>> /// <param name="d"></param>
>> /// <param name="args"></param>
>> /// <Author>Oscar Thornell</Author>
>> public static void Execute(Delegate d, params object[] args)
>> {
>> ThreadPool.QueueUserWorkItem(callback, new TargetInfo(d, args));
>> }
>>
>> private static void DynamicInvokeShim(object obj)
>> {
>> TargetInfo targetInfo = (TargetInfo)obj;
>> targetInfo.Target.DynamicInvoke(targetInfo.Args);
>> }
>>
>> class TargetInfo
>> {
>> internal readonly Delegate Target;
>> internal readonly object[] Args;
>>
>> internal TargetInfo(Delegate d, object[] args)
>> {
>> Target = d;
>> Args = args;
>> }
>> }
>> }
>> }
>>
>>
>>
>> "JV" <oyeahright@spammenot.com> wrote in message
>> news:Oi58pwqRGHA.252@TK2MSFTNGP10.phx.gbl...[color=darkred]
>>> My ASP.NET application needs to accept data from a post and return
>>> quickly. I've added a worker thread to wake up and save data
>>> asynchronously after the data is received. But, it appears to me that
>>> IIS kills the process and thus the worker thread right after my main
>>> ASP.NET thread returns (anyone know for certain?).
>>>
>>> Do you know of a design pattern to accomplish this?
>>>[/color]
>>
>>[/color]
>
>[/color]