2014-05-10 35 views
0

我有從圖像庫中獲得的圖像,應該將其發送到服務器作爲基本字符串但是調用挑圖像是我轉移到當一個函數圖書館頁面,但不要等到我選擇繼續發送空的數據到服務器。使用Windows Phone上的圖像拾取劑量不會等到在Windows Phone 8選擇的圖像

public void Chplaceimg(string PlaceID) 
{ 
    YOimage changeplaceimg = new YOimage(); 

    if (changeplaceimg.pickImage() != null) 
    { 
     var pairs = new List<KeyValuePair<string, string>> 
     { 
      new KeyValuePair<string, string> ("id", _id), 
      new KeyValuePair<string, string> ("image", changeplaceimg._base64Image), 
      new KeyValuePair<string, string> ("place", PlaceID) 
     }; 
     var serverData = serverConnection.connect("image.php", pairs); 
    } 
} 

public bool pickImage() 
{ 
    var photoChooserTask = new PhotoChooserTask(); 
    photoChooserTask.Completed += PhotoChooserTaskCompleted; 
    photoChooserTask.Show(); 
    return true; 
} 

//run function convertToBase64 when an image is choosed 
private void PhotoChooserTaskCompleted(object sender, PhotoResult e) 
{ 
    if (e.TaskResult == TaskResult.OK) 
    { 
     convertToBase64(e); 
    } 

} 

回答

0

您必須撥打服務電話作爲PhotoChooserTaskCompleted回撥的一部分。

//run function convertToBase64 when an image is choosed 
private void PhotoChooserTaskCompleted(object sender, PhotoResult e) 
{ 
    if (e.TaskResult == TaskResult.OK) 
    { 
     // send data to server here 
     convertToBase64(e); 
    } 
} 
+0

但功能和參數在不同的類 – MohamedAbbas

+0

所以重新組織它,使之成爲可能。沒有其他方法,因爲WP是全部異步的,並且基於回調。 – MarcinJuraszek