Connecting Tech Pros Worldwide Forums | Help | Site Map

Ahh, getting crazy over this.

Fredrik Melin
Guest
 
Posts: n/a
#1: Nov 20 '05
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



Dmitriy Lapshin [C# / .NET MVP]
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Ahh, getting crazy over this.


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" <mel@n.o.spam.dacsa.net.remove.as.needed> wrote in message
news:nLOdnX9ET7hF7S6iRVn-jg@giganews.com...[color=blue]
> Same problem that I had before, diffrent approach..
>
> In my application at order-creation, the user might encounter that the[/color]
item[color=blue]
> 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[/color]
the[color=blue]
> "wait handler function", so it will call it in a new thread, but the[/color]
actual[color=blue]
> 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[/color]
dont[color=blue]
> 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[/color]
be[color=blue]
> done the way I describe above?
> Or am I on the wrong road? (maybe even in the wrong city :-/ )
>
> Regards
> Fredrik Melin
>
>[/color]

Fredrik Melin
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Ahh, getting crazy over this.


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 [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com> wrote
in message news:uGkH4QfqDHA.2488@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi,
>
> There are two approaches:
>
> 1. A simple one.
>
> Do a quick test whether the order is locked and render a simple page[/color]
saying[color=blue]
> "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[/color]
page[color=blue]
> 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" <mel@n.o.spam.dacsa.net.remove.as.needed> wrote in message
> news:nLOdnX9ET7hF7S6iRVn-jg@giganews.com...[color=green]
> > Same problem that I had before, diffrent approach..
> >
> > In my application at order-creation, the user might encounter that the[/color]
> item[color=green]
> > he is trying to order is locked by another user, and he have to wait up[/color][/color]
to[color=blue][color=green]
> > 45 seconds for it to release.
> >
> >
> > Now, In my windows application that is no problem, I simply call a[/color][/color]
dialog[color=blue][color=green]
> > 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[/color]
> the[color=green]
> > "wait handler function", so it will call it in a new thread, but the[/color]
> actual[color=green]
> > 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[/color]
> dont[color=green]
> > know where the wait method is created, if no-one sending a reference to[/color][/color]
a[color=blue][color=green]
> > wait method to the lock object, it will generate an error (or just[/color][/color]
simply[color=blue][color=green]
> > 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[/color][/color]
the[color=blue][color=green]
> > same class as the function that does the delegated procedure, but can it[/color]
> be[color=green]
> > done the way I describe above?
> > Or am I on the wrong road? (maybe even in the wrong city :-/ )
> >
> > Regards
> > Fredrik Melin
> >
> >[/color]
>[/color]


Fredrik Melin
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Ahh, getting crazy over this.


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" <mel@n.o.spam.dacsa.net.remove.as.needed> wrote in message
news:aZOdnRwcdI0bBi6iRVn-jw@giganews.com...[color=blue]
> The threads are already there, because in the Windows environment, the[/color]
user[color=blue]
> 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[/color]
some[color=blue]
> other callback method.
>
> - Fredrik
>
> "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com> wrote
> in message news:uGkH4QfqDHA.2488@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi,
> >
> > There are two approaches:
> >
> > 1. A simple one.
> >
> > Do a quick test whether the order is locked and render a simple page[/color]
> saying[color=green]
> > "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[/color]
> page[color=green]
> > saying, "Please wait while the order is released...." which would[/color][/color]
refresh[color=blue][color=green]
> > itself, say, every 10 seconds or so through the <META NAME="Refresh">[/color][/color]
HTML[color=blue][color=green]
> > tag. Once the order has been released, process it and render another[/color][/color]
page[color=blue][color=green]
> > 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" <mel@n.o.spam.dacsa.net.remove.as.needed> wrote in[/color][/color]
message[color=blue][color=green]
> > news:nLOdnX9ET7hF7S6iRVn-jg@giganews.com...[color=darkred]
> > > Same problem that I had before, diffrent approach..
> > >
> > > In my application at order-creation, the user might encounter that the[/color]
> > item[color=darkred]
> > > he is trying to order is locked by another user, and he have to wait[/color][/color][/color]
up[color=blue]
> to[color=green][color=darkred]
> > > 45 seconds for it to release.
> > >
> > >
> > > Now, In my windows application that is no problem, I simply call a[/color][/color]
> dialog[color=green][color=darkred]
> > > box in a new thread, that show the information, everything works[/color][/color][/color]
great.[color=blue][color=green][color=darkred]
> > >
> > > Ok, for a ASP.NET application the problem starts, because the new[/color][/color][/color]
thread[color=blue][color=green][color=darkred]
> > > created does not have access the context, and therefor cannot write[/color][/color][/color]
any[color=blue][color=green][color=darkred]
> > > "waiting" information to the user.
> > >
> > > What I need to do is, somehow send in a reference to the Lock object[/color][/color][/color]
of[color=blue][color=green]
> > the[color=darkred]
> > > "wait handler function", so it will call it in a new thread, but the[/color]
> > actual[color=darkred]
> > > 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[/color][/color][/color]
it[color=blue][color=green]
> > dont[color=darkred]
> > > know where the wait method is created, if no-one sending a reference[/color][/color][/color]
to[color=blue]
> a[color=green][color=darkred]
> > > wait method to the lock object, it will generate an error (or just[/color][/color]
> simply[color=green][color=darkred]
> > > skip the wait information stage)
> > >
> > > So I need to send in a "Address Of" to the lock object, and it will[/color][/color][/color]
then[color=blue][color=green][color=darkred]
> > > start that procedure in a new thread.
> > >
> > > All delegates samples Ive seen, you have the caller of the function in[/color][/color]
> the[color=green][color=darkred]
> > > same class as the function that does the delegated procedure, but can[/color][/color][/color]
it[color=blue][color=green]
> > be[color=darkred]
> > > done the way I describe above?
> > > Or am I on the wrong road? (maybe even in the wrong city :-/ )
> > >
> > > Regards
> > > Fredrik Melin
> > >
> > >[/color]
> >[/color]
>
>[/color]


Closed Thread


Similar Visual Basic .NET bytes