Async Everything!
So I've been migrating my old little windows phone 8 app to UWP for a while now.
But there's a little thing that I just come over with is this "async with out referencing". After a little googling I found that it is not possible to have out referencing with async because of a technical issue.
After reading some proposed workaround. I've come up with my idea to MIMICK the out reference syntax:I often out-referencing variables because of the Try-Out combo. So I can write something like this:With this little helper class, I can keep the old syntax as clear as before and keep the syntax structure look-alike:
However it only works on this condition. If you want the returned result to be a different type. You may want to extend this class with it... ANNnnd it is not practical to just extend each return type with a mostly identical class.
Urgh, nevermind.
But there's a little thing that I just come over with is this "async with out referencing". After a little googling I found that it is not possible to have out referencing with async because of a technical issue.
After reading some proposed workaround. I've come up with my idea to MIMICK the out reference syntax:
public class AsyncTryOut<T>
{
public bool Status = false;
public T Out;
public AsyncTryOut() { }
public AsyncTryOut( bool b, T r )
{
Status = b;
Out = r;
}
public static bool operator true( AsyncTryOut<T> s ) { return s.Status; }
public static bool operator false( AsyncTryOut<T> s ) { return s.Status; }
}Stream s = null;
// Search Phone library
if ( wStorage.TryGetImgFromLib( "wenku8_" + id, out s ) )
{
// Do something with s
}
...AsyncTryOut<Stream> = null;
// Search Phone library
if ( ato = wStorage.TryGetImgFromLib( "wenku8_" + id ) )
{
Stream s = ato.Out;
// Do something with s
}
..However it only works on this condition. If you want the returned result to be a different type. You may want to extend this class with it... ANNnnd it is not practical to just extend each return type with a mostly identical class.
Urgh, nevermind.
Sat Sep 19 2015 15:53:35 GMT+0000 (Coordinated Universal Time)
Last modified: Fri Mar 11 2016 14:31:41 GMT+0000 (Coordinated Universal Time)
Comments
No comments here.
Do you even comment?
website:
Not a valid website
Invalid email format
Please enter your email
*Name:
Please enter a name
Submit
抱歉,Google Recaptcha 服務被牆掉了,所以不能回覆了