Question

on windows phone 8 i have a function that get an image from image library and should send it to the server as base string however when calling pick image it transfer me to library page but dose not wait till i pick it continues to send empty data to the server.

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);
    }

}
Was it helpful?

Solution

You have to make service call as part of PhotoChooserTaskCompleted callback.

//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);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top