这是我想要实现的目标。
我有一个登录类。一旦用户通过身份验证,一些登录后操作将在一个线程中完成。用户进入主页。
现在从主页我转到一个不同的功能,比如类 FindProduct。我需要检查登录线程中的登录后操作是否完成。只有在登录后操作完成后,我才允许进入该功能。
我是否必须在 PerformLoginAsyncThread 和 OnClickFindProduct 上放置等待句柄?
Class Login
{
public bool Login(Userinfo)
{
// do tasks like authenticate
if(authenticationValid)
{
PerformLoginAsyncThread(UserInfo)
//continue to homepage
}
}
}
Class HomePage
{
public void OnClickFindProduct
{
if(finishedPostLoginThread)
// proceed to Find Product page
else
{
//If taking more than 8 seconds, throw message and exit app
}
}
}