Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MyFunction()
- {
- Session["UserID"] = SomeProprietarySessionManagementLookup();
- Response.Redirect("SomeOtherPage.aspx");
- }
- int MyFunction(int x, int x)
- {
- try
- {
- return x / y;
- }
- catch(Exception ex)
- {
- // log it
- throw;
- }
- }
- int MyFunction(int x, int y, out bool isSuccessful)
- {
- isSuccessful = false;
- if (y == 0)
- return 0;
- isSuccessful = true;
- return x / y;
- }
- int MyFunction(int x, int y)
- {
- if (y == 0)
- {
- // log it
- throw new DivideByZeroException("Divide by zero attempted!");
- }
- return x / y;
- }
- Session["UserID"] = SomeProprietarySessionManagementLookup();
- public void SomeProprietarySessionManagementLookup()
- {
- // do some async lookup
- Action<object> d = delegate(object val)
- {
- LookupSession(); // long running thing that looks up the user.
- Session["UserID"] = 1234; // Setting session manually
- };
- d.BeginInvoke(null,null,null);
- }
- Action<object> d = delegate(object val)
- {
- System.Threading.Thread.Sleep(1000); // waits a little
- Session["rubbish"] = DateTime.Now;
- };
- d.BeginInvoke(null, null, null);
- System.Threading.Thread.Sleep(5000); // waits a lot
- object stuff = Session["rubbish"];
- if( stuff == null ) stuff = "not there";
- divStuff.InnerHtml = Convert.ToString(stuff);
- Action<object> d = delegate(object val)
- {
- System.Threading.Thread.Sleep(5000); // waits a lot
- Session["rubbish"] = DateTime.Now;
- };
- d.BeginInvoke(null, null, null);
- // wait removed - ends immediately.
- object stuff = Session["rubbish"];
- if( stuff == null ) stuff = "not there";
- divStuff.InnerHtml = Convert.ToString(stuff);
- Session["UserID"] = SomeProprietarySessionManagementLookup();
- SomeProprietarySessionManagementLookup(Session["UserID"]);
Add Comment
Please, Sign In to add comment