Ahh, getting crazy over this.

  • Thread starter Thread starter Fredrik Melin
  • Start date Start date
F

Fredrik Melin

Same problem that I had before, diffrent approach..

In my application at order-creation, the user might encounter that the item
he is trying to order is locked by another user, and he have to wait up to
45 seconds for it to release.


Now, In my windows application that is no problem, I simply call a dialog
box in a new thread, that show the information, everything works great.

Ok, for a ASP.NET application the problem starts, because the new thread
created does not have access the context, and therefor cannot write any
"waiting" information to the user.

What I need to do is, somehow send in a reference to the Lock object of the
"wait handler function", so it will call it in a new thread, but the actual
function is made by the ASP.NET page.

Delegates huh?

In other words:

You have the lock object, it knows it will call "Wait" function, but it dont
know where the wait method is created, if no-one sending a reference to a
wait method to the lock object, it will generate an error (or just simply
skip the wait information stage)

So I need to send in a "Address Of" to the lock object, and it will then
start that procedure in a new thread.

All delegates samples Ive seen, you have the caller of the function in the
same class as the function that does the delegated procedure, but can it be
done the way I describe above?
Or am I on the wrong road? (maybe even in the wrong city :-/ )

Regards
Fredrik Melin
 
Hi,

There are two approaches:

1. A simple one.

Do a quick test whether the order is locked and render a simple page saying
"Please try again in a few minutes" if the order is indeed locked.

2. A more complex one.

Do a quick test whether the order is locked. If this is true, render a page
saying, "Please wait while the order is released...." which would refresh
itself, say, every 10 seconds or so through the <META NAME="Refresh"> HTML
tag. Once the order has been released, process it and render another page
saying "Processing complete".

No need for threads and delegates :-)
 
The threads are already there, because in the Windows environment, the user
get options to cancel or add more wait time, so the functionallity is
already there, thats why I wanted the nice display for the web as well,
simular to what I already have in the Windows enviroment.

So, I really want to get it to work with the ASP.NET via a delegate or some
other callback method.

- Fredrik

Dmitriy Lapshin said:
Hi,

There are two approaches:

1. A simple one.

Do a quick test whether the order is locked and render a simple page saying
"Please try again in a few minutes" if the order is indeed locked.

2. A more complex one.

Do a quick test whether the order is locked. If this is true, render a page
saying, "Please wait while the order is released...." which would refresh
itself, say, every 10 seconds or so through the <META NAME="Refresh"> HTML
tag. Once the order has been released, process it and render another page
saying "Processing complete".

No need for threads and delegates :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Fredrik Melin said:
Same problem that I had before, diffrent approach..

In my application at order-creation, the user might encounter that the item
he is trying to order is locked by another user, and he have to wait up to
45 seconds for it to release.


Now, In my windows application that is no problem, I simply call a dialog
box in a new thread, that show the information, everything works great.

Ok, for a ASP.NET application the problem starts, because the new thread
created does not have access the context, and therefor cannot write any
"waiting" information to the user.

What I need to do is, somehow send in a reference to the Lock object of the
"wait handler function", so it will call it in a new thread, but the actual
function is made by the ASP.NET page.

Delegates huh?

In other words:

You have the lock object, it knows it will call "Wait" function, but it dont
know where the wait method is created, if no-one sending a reference to a
wait method to the lock object, it will generate an error (or just simply
skip the wait information stage)

So I need to send in a "Address Of" to the lock object, and it will then
start that procedure in a new thread.

All delegates samples Ive seen, you have the caller of the function in the
same class as the function that does the delegated procedure, but can it be
done the way I describe above?
Or am I on the wrong road? (maybe even in the wrong city :-/ )

Regards
Fredrik Melin
 
Solved this.

Using the "ugly" way, but it works.

I let the Lock object in my support library take a optional parameter of the
HttpContext
Then the ASP.NET sends in the HttpContext, which then is sent to the routine
that shows waiting information, now I can send text information back to the
user.

Windows application isnt affected because it will not have any Httpcontext
to send into the function.

- Fredrik


Fredrik Melin said:
The threads are already there, because in the Windows environment, the user
get options to cancel or add more wait time, so the functionallity is
already there, thats why I wanted the nice display for the web as well,
simular to what I already have in the Windows enviroment.

So, I really want to get it to work with the ASP.NET via a delegate or some
other callback method.

- Fredrik

Dmitriy Lapshin said:
Hi,

There are two approaches:

1. A simple one.

Do a quick test whether the order is locked and render a simple page saying
"Please try again in a few minutes" if the order is indeed locked.

2. A more complex one.

Do a quick test whether the order is locked. If this is true, render a page
saying, "Please wait while the order is released...." which would refresh
itself, say, every 10 seconds or so through the <META NAME="Refresh"> HTML
tag. Once the order has been released, process it and render another page
saying "Processing complete".

No need for threads and delegates :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Same problem that I had before, diffrent approach..

In my application at order-creation, the user might encounter that the item
he is trying to order is locked by another user, and he have to wait
up
to of
the it
dont
to
 
Back
Top