B
Borr
Hi,
I am writing an ASP .NET application that has a following
logic : if one of application users performs some specific
action, ALL other users that are browsing some page (lets
call it "WaitingForSpecificAction.aspx"), should get event
that this action is performed.
How to do it ?
I defined class like this :
public class EventManager
{
public delegate void ActionPerformed(object source,
EventArgs e);
public event ActionPerformed OnActionPerformed;
public void PerformAction()
{
... // Fill EventArgs e variable
if (OnActionPerformed != null) {
OnActionPerformed(this, e);
}
}
}
This class instance is an entry in Application collection
and can be accessed as Application["EntryName"]. I call
PerformAction() method from a page where the user can
perform the action.
-------
On "WaitingForSpecificAction.aspx" I subscribe on
OnActionPerformed event :
EventManager em = Application["EntryName"] as EntryManager;
em.OnActionPerformed += new EventManager.ActionPerformed
(OnActionPerformed);
and define OnActionPerformed event handler :
private void OnActionPerformed (object source, GameEvent e)
{
...
}
It does not work ! For example, if OnActionPerformed()
method contains Response.Redirect or Server.Transfer
calls, it fails. Probably it is because of event is raised
in one session and handled in another one. But ... HOW TO
DO IT CORRECTLY ?
I am writing an ASP .NET application that has a following
logic : if one of application users performs some specific
action, ALL other users that are browsing some page (lets
call it "WaitingForSpecificAction.aspx"), should get event
that this action is performed.
How to do it ?
I defined class like this :
public class EventManager
{
public delegate void ActionPerformed(object source,
EventArgs e);
public event ActionPerformed OnActionPerformed;
public void PerformAction()
{
... // Fill EventArgs e variable
if (OnActionPerformed != null) {
OnActionPerformed(this, e);
}
}
}
This class instance is an entry in Application collection
and can be accessed as Application["EntryName"]. I call
PerformAction() method from a page where the user can
perform the action.
-------
On "WaitingForSpecificAction.aspx" I subscribe on
OnActionPerformed event :
EventManager em = Application["EntryName"] as EntryManager;
em.OnActionPerformed += new EventManager.ActionPerformed
(OnActionPerformed);
and define OnActionPerformed event handler :
private void OnActionPerformed (object source, GameEvent e)
{
...
}
It does not work ! For example, if OnActionPerformed()
method contains Response.Redirect or Server.Transfer
calls, it fails. Probably it is because of event is raised
in one session and handled in another one. But ... HOW TO
DO IT CORRECTLY ?