I'm quite new with facebooksdk, but I have a winform project in c# to perform simple status posting & photo upload using it.
So far so good with the SDK, however, what's the difference between FacebookClient.Post & FacebookClient.PostTaskAync?
I used the following code to post photo to my facebook account:
public static void uploadPhoto(string fPath, string userMsg, string imgType = "")
{
var fb = new FacebookClient(AccessToken);
if (imgType.Equals(""))
imgType = "image/jpeg";
using (var file = new FacebookMediaStream
{
ContentType = imgType,
FileName = Path.GetFileName(fPath)
}.SetValue(File.OpenRead(fPath)))
{
dynamic result = fb.Post("me/photos",
new { message = userMsg, file });
}
}
But, when the file size is huge, the above method will "hang" my system as the main thread is still working, so I tried the following:
dynamic result = fb.PostTaskAsync("me/photos",
new { message = userMsg, file });
but it just doesn't work (at least the photo is not being uploaded to my fb account)...
What I want actually is to avoid the "hanging" feeling on my system, and I've even tried "Application.DoEvents()" but with NO luck.
Any suggestion to handle for this issue? Shall I use another Thread to handle this photo upload? Or?
Thanks for all the answers & comments.