silverlight的执行顺序很奇怪
我想要登录表单,用户通过该登录表单输入用户名和密码(如果正确),那么它将检查首次登录(如果用户第一次登录),然后页面 shd 重定向到更改密码表单 我想在 silverlight 中实现此功能 我正在使用 wcf 服务编写代码,所以我的逻辑是我将用户名存储在会话中,然后将其重定向到更改密码表单,但有时它会先存储用户名,然后重定向到更改密码表单,这是正确的,但下次如果我执行相同的表单,那么它首先重定向到更改密码表单,然后设置用户名会话所以即使用户名是正确的,它也会重定向到登录表单,请帮助我,这让我发疯。 这是我的代码
gen.SetSessionVariableAsync("uname", username.Text); App.Navigate(new UserMgt.Changepassword());
因此,理想情况下,第一行应该执行第一行,第二行应该执行第二行,但有时第一次首先编译,有时第二次首先编译。
所以首先我设置会话变量,然后我想将其重定向到更改密码页面,但这里有时它确实正确,但有时它首先重定向到更改密码然后设置为会话变量为什么会这样?顺序有什么问题的顺序?
请让我知道 silverlight 执行的句子顺序。任何帮助都将得到高度重视。您可以通过 [电子邮件受保护] 以及。
I want login form through which user enter user name and password if it is correct then it will check for first time login if user login for first time then page shd redirect to change password form i want to implement this in silverlight i am using wcf service to write the code so my logic is i am storing the username in session and then i am redirect it to change password form but sometimes it stores username first and then redirect to change password form which is correct but next time if i execute same form then it first redirect to change password form and then it set the username session so even username is correct it redirect to login form please help me it is making me crazy.
here is my code
gen.SetSessionVariableAsync("uname", username.Text);
App.Navigate(new UserMgt.Changepassword());
so ideally first line should execute first and second line executes second but here some times first time compile first and some time second time first.
so first i am setting session variable then i want to redirect it to change password page but here sometimes it does proper but sometimes it first redirect to change password then it set to session variable why it is like this?what is the wrong with the order of sequence?
please let me know order of sentence silverlight executes..any help will be highly appropriated.you can email me on [email protected] as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法按照编写代码的顺序完成异步操作。使其按顺序工作的方法是使用 Async 方法上的 Completed 事件,然后执行以下方法,如下所示:
请注意,我在上面的代码片段中使用了 lambda 表达式。
You cannot get async operations to complete in the order in which you write the code. The way to get this working in sequence is by using the Completed event on the Async method and then to execute the following method there as below:
Note that I am using lambda expressions in the above code fragment.
由于 SetSessionVariableAsync() 方法是异步的,因此无法保证它何时完成。如果您必须先完成该操作,请在第一个方法的完成事件中触发第二个方法。
Because the SetSessionVariableAsync() method is asynchronous then there is no guarantee when it finishes. If you MUST have that finish first, fire the second method in the completed event for the first method.