By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,278 Members | 1,106 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,278 IT Pros & Developers. It's quick & easy.

Please help.. .can't make this work on win 2k3 (delegates related)

P: n/a
Hi, thanks for reading. I hope to find some help here
before I commit suicide because this is driving me crazy.

Please excuse me if this looks like a long post, but I
hope that a complete explanation help you to help
me :=) ....Let's start with some background:
..- I'm building an asp.net application that requires users
to upload text files in cvs format with data exported from
an AS-400.
..- The files will be something between 800kb and 2mb.
..- I have to parse those files, and get data to fill an
typed dataset.
..- I have to present dataset contents before submitting
anything to database
..- I'm stuck with only asp.net and sql server. I can't
build windows services, use msmq or anything else.

My biggest concern is that the browser can timeout before
i finish all processes. This is what I've done so far:

1.- Built a class that takes a file path as parameter in
the constructor. This class have the following method:
protected ArrayList getLines()

{

reader = File.OpenText(_fileName);

ArrayList array = new ArrayList();

string str;

string[] valuesList;

do

{

str = reader.ReadLine();

if(str!=null)

{

valuesList = str.Split(new char[] {';'});

array.Add(valuesList);

}

}while(str!=null);

reader.Close();

return array;

}

As you can see, this base class handles the file itself,
converting the data to a more friendly arraylist

2.- Built a class that inherits the first class. This
class has a methos (the one that takes long) that iterates
thought all items in the ArrayList. I won't post the code
because is quite large but basicly it takes each item in
the array, examinate the data and invokes several methods
that create new rows inside dataset tables and fill them
with data. At the end returns the filled dataset. This
method recieve as parameter an instance of another class
that manages user data and permissions.

3.- In my web form I've done the following:
A.- declared an delegate (Nomisistemas.Reciept is the
typed dataset, "file" is the uploaded file
path, "Nomisistemas.NSWorker" is the instance of the class
that manages user data, "connectionString" is the
connection string to the database.
public delegate Nomisistemas.Receipt testDelegate(string
file, Nomisistemas.NSWorker worker, string
connectionstring);

B.- in the web form Page_Load event handler i do:
(processReceiptFile is a method that I'll explain later)
myDelegate = new testDelegate(this.processReceiptFile);

C.- The processReceiptFile method is:
public Receipt processReceiptFile2(string fileName,
NSWorker usrWorker, string connectionString)

{

receiptsProcessor myReceipt = new receiptsProcessor
(fileName,usrWorker,connectionString);

return myReceipt.getReceiptsDataSet();

}

D.- In a button event handler, after i've managed the file
upload I do:
Session["Complete"] = false;

myDelegate.BeginInvoke
(fileName,usrWorker,connectionString,new AsyncCallback
(myCallback),myDelegate);

Response.Redirect("dataAdminReceipt.aspx");

E.- myCallback is:
public void myCallback(IAsyncResult res)

{

testDelegate myDelegate = (testDelegate)
res.AsyncState;

Receipt ds = myDelegate.EndInvoke(res);

Session["data"] = ds;

Session["Complete"] = true;

}

F.- In the dataAdminReceipt.aspx's Page_Load event handler
I'm doing:
if(!Page.IsPostBack)

{

if(!Convert.ToBoolean(Session["Complete"]))

{

Response.Write("<META HTTP-EQUIV=Refresh
CONTENT='3; URL='>");

}

else

{

//Continue with the process....

}

}


So what I want to do is to lauch the delegate.BeginInvoke
and go to another page to monitor the value of Session
["complete"], until is true. This idea is not mine, I'm
copying this from this tutorial .

So.. my problems.... This work great on my workstation
(windows xp pro sp1). Here everything run smothly.. But,
when I upload this app to a fresh installation of windows
2003 it fails. But doesn't throw any exception or
complains in anyway.. It just doesn't run. My session
variable never changes. And to make it worst, if I
implement a simpler application that uses this methodology
but doesn't use any of my custom objects IT WORKS ON THE
SERVER!.

I've tried to use threads directly, but also fails. Also
tried to serialize the dataset just to check if it has
something to do with Session variables, but also fails if
I'm doing it in the async way.. If i run it secuencially
(no delegates or threads) it also works in the server
(OMG!)

I've checked permissions, reinstalled the server, made
asp.net an administrator, impersonation to an
administrator, prayed to god and all angels, but no
sucess... any idea?.. please :'(

Thanks for reading again :).. I know you will show me the
light....
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Esteban Felipe" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hi, thanks for reading. I hope to find some help here
before I commit suicide because this is driving me crazy.


As soon as you call Response.Redirect, the page you called it from is
destroyed, along with the Request, Response, Context and Server objects.
Since youd delegate is executing after all of this has been destroyed, it
will not have a pleasant time.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.