Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

web api dead lock

$
0
0

does anyone have a idea on how to make this code not cause the app to crash/lag? i do not get any stack trace from the crash.
` private async Task zregisterz()//(byte[] zpic)
{
try{
/* byte[] zpic;
var zstream = new System.IO.MemoryStream ();
using (Bitmap zProfilezPic = BitmapFactory.DecodeResource (Resources, Resource.Drawable.zprofile)) {
await zProfilezPic.CompressAsync (Bitmap.CompressFormat.Png, 0, zstream);
zpic = zstream.ToArray ();
}/
EditText zSPass =zReg. FindViewById (Resource.Id.txtPassword);
EditText zN = zReg.FindViewById (Resource.Id.txtzName);
EditText zFPass = zReg.FindViewById (Resource.Id.zPassword);
string zuserstolow = zN.Text.Trim ().ToLower ();
string zpasstolow = zFPass.Text.Trim ().ToLower ();
zUsers zu = new zUsers ();
zu.zName = zuserstolow;
zu.zPass = zHash.CreateHash(zpasstolow);
zu.zaGan=1000M;
// zu.zProfilePic = zpic;
string jz = JsonConvert.SerializeObject(zu.zName);
Match match = Regex.Match (zuserstolow, @^[0-9-]
$");
HttpWebRequest zrequest = null;
string zWebSite = string.Format("http://192.168.0.12:54946/api/zUsers/zRegister/{0}/a/a",zu.zName);
zrequest = (HttpWebRequest)WebRequest.Create(zWebSite);
zrequest.Proxy = null;
var data = Encoding.ASCII.GetBytes(jz);
zrequest.Method = "POST";
zrequest.ContentType = "application/json";
zrequest.ContentLength = data.Length;
using (var str = zrequest.GetRequestStream())
{
await Task.Run((async () => await str.WriteAsync(data, 0, data.Length)));
}
var response = (HttpWebResponse)zrequest.GetResponse();
string responseString = await new StreamReader(response.GetResponseStream()).ReadToEndAsync().ConfigureAwait(false);
if (responseString != "\"\"") {zAlert ("the user " + zuserstolow + " already exists", ui);}
else if (zN.Text == string.Empty || string.IsNullOrEmpty (zN.Text) || string.IsNullOrWhiteSpace (zN.Text)) {zAlert ("name cannot be blank.", ui);}
else if (zFPass.Text == string.Empty || string.IsNullOrEmpty (zFPass.Text) || string.IsNullOrWhiteSpace (zFPass.Text)) { zAlert ("Password cannot be blank.", ui);}
else if (zSPass.Text == string.Empty|| string.IsNullOrEmpty (zSPass.Text) || string.IsNullOrWhiteSpace (zSPass.Text)) {zAlert ("Password cannot be blank.", ui);}
else if (zFPass.Text.Length > 23) {zAlert ("your password cant be more than 23 charecters.", ui);}
else if (zFPass.Text.Length < 5) {zAlert ("your password has to be longer than 5 charecters long.", ui);}
else if (match.Success) {zAlert ("your zName has a invald charecter.", ui);}
else if (zSPass.Text.Length > 23) {zAlert ("your zpass cannot be longer than 22 charecters.", ui);}
else if (zSPass.Text.Length < 5) {zAlert ("your zpass has to be longer than 6 charecters.", ui);}
else if (zN.Text.Length == 16 || zN.Text.Length > 16) {zAlert ("zName cannot be longer than 15 charecters.", ui);}
else if (zFPass.Text != zSPass.Text) {zAlert ("the passwords do not match.", ui);}
else {zEditTxtV(ui); zAlert("you succesfully created an account " + zu.zName+ ".", ui);
}
}

        catch(Exception) {zAlert ("something is wrong with your connection", ui);}

    }`

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>