473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

having beginner troubles with asynchronous calls in asp.net

Hi all, sorry if this is an over simple question but google isn't
coming through for me.

So I have a class that processes the data in an excel file, entering
the info row by row into our database. The public interface is as such:
public class ExcelToQueueEngine
{
public ExcelToQueueEngine(string ConnectionString)
{
//constructor
_connStr = ConnectionString;
}

public void ProcessFile(string pathToExcelFile, int archiveId)
{
//do my row processing
}
}

This processing can take 5+ minutes, so i'd like to call the
ProcessFile method asynchronously, and let the web user go on their
merry way. I have extensive logging/tracing in the ProcessFile method,
so I dont need ( and especially don't want) to have to tie up the aspx
page that calls this method to worry about the IAsynchResult return. So
basically the process is started and the web page returns, and the
processing thread does all the excel work. My aspx code is:

ExcelToQueueEngine eng = new ExcelToQueueEngine(_connStr);
AsynchProcessDelegate del = new AsynchProcessDelegate(eng.ProcessFile);
del.BeginInvoke(filePath, archiveId, null, null);

It seems to be that the BeginInvoke is called, but then the processing
stops as the page returns to the user. Any ideas what I'm doing wrong?

Thanks in advance.

Feb 7 '06 #1
2 1130
you have to start a new tread to do the async processing, not use the
current request thread. when the current request completes (sends page to
browser), the thread is returned to the request pool. it may be processing
another request when the delegate fires, or if no requests have come along,
the thread may exit.

-- bruce (sqlwork.com)

"do******@runwithscissors.org" <do****@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi all, sorry if this is an over simple question but google isn't
coming through for me.

So I have a class that processes the data in an excel file, entering
the info row by row into our database. The public interface is as such:
public class ExcelToQueueEngine
{
public ExcelToQueueEngine(string ConnectionString)
{
//constructor
_connStr = ConnectionString;
}

public void ProcessFile(string pathToExcelFile, int archiveId)
{
//do my row processing
}
}

This processing can take 5+ minutes, so i'd like to call the
ProcessFile method asynchronously, and let the web user go on their
merry way. I have extensive logging/tracing in the ProcessFile method,
so I dont need ( and especially don't want) to have to tie up the aspx
page that calls this method to worry about the IAsynchResult return. So
basically the process is started and the web page returns, and the
processing thread does all the excel work. My aspx code is:

ExcelToQueueEngine eng = new ExcelToQueueEngine(_connStr);
AsynchProcessDelegate del = new AsynchProcessDelegate(eng.ProcessFile);
del.BeginInvoke(filePath, archiveId, null, null);

It seems to be that the BeginInvoke is called, but then the processing
stops as the page returns to the user. Any ideas what I'm doing wrong?

Thanks in advance.

Feb 7 '06 #2
don_spam,
As Bruce suggested, a Page Lifecycle isn't a good place to spawn an
asynchronous process that can take 5+ minutes. You could create a class with
a method to do this and store it in Global or in Application State, and have
some sort of callback mechanism to notify of results.
Here's a little piece I did recently that illustrates what's involved. This
isn't asynch- its just a background thread, but the concept is the same.

http://www.eggheadcafe.com/articles/20051223.asp

Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"do******@runwithscissors.org" wrote:
Hi all, sorry if this is an over simple question but google isn't
coming through for me.

So I have a class that processes the data in an excel file, entering
the info row by row into our database. The public interface is as such:
public class ExcelToQueueEngine
{
public ExcelToQueueEngine(string ConnectionString)
{
//constructor
_connStr = ConnectionString;
}

public void ProcessFile(string pathToExcelFile, int archiveId)
{
//do my row processing
}
}

This processing can take 5+ minutes, so i'd like to call the
ProcessFile method asynchronously, and let the web user go on their
merry way. I have extensive logging/tracing in the ProcessFile method,
so I dont need ( and especially don't want) to have to tie up the aspx
page that calls this method to worry about the IAsynchResult return. So
basically the process is started and the web page returns, and the
processing thread does all the excel work. My aspx code is:

ExcelToQueueEngine eng = new ExcelToQueueEngine(_connStr);
AsynchProcessDelegate del = new AsynchProcessDelegate(eng.ProcessFile);
del.BeginInvoke(filePath, archiveId, null, null);

It seems to be that the BeginInvoke is called, but then the processing
stops as the page returns to the user. Any ideas what I'm doing wrong?

Thanks in advance.

Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Richard | last post by:
Hi, I'm suffering a socket race condition - I think. The code works fine at full speed on a single CPU machine. However when I run full speed on a 2 Zeon machine the socket drops data on an...
1
by: Alexander Kaplunov | last post by:
I have two different scenarios: 1. I have an application that calls a web service and passes an object. Web Service takes that object and does some stuff with it, which could take...
3
by: usenetaccount | last post by:
In a newly created test app, to maximize client performance I tried to make two SOAP method calls in tandem (the soap methods execute some specified query), as each call includes a large amount of...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
0
by: Bishoy George | last post by:
Hi, I have a asp.net 2.0 web application. I want to implement the asynchronous model through http handler in web.config ...
6
by: Pat B | last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol using C#. I have implemented it using BeginReceive and EndReceive calls so as not to block when waiting for data from the...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
2
by: =?Utf-8?B?S2FseWFu?= | last post by:
Hi, I have to make multiple calls (about 400K) to a webservice which returns a string. And currently it takes about a week to make all the calls. Instead of waiting for the webservice result ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.