1
我想使用Magento的C#RESTAPI庫連接到我的Magento商店。 我成功地連接到它,然後我想通過它的SKU獲得產品。我選擇了去尋找現有的SKU,我寫了這個代碼:Magento的C#RESTAPI調用凍結我的應用程序
private void button1_Click(object sender, EventArgs e)
{
var client = new MagentoApi()
.SetCustomAdminUrlPart("index.php/admin")
.Initialize("http://www.example.com/magento/",
"57348583384fh8h83h4334h34", "8vh388hhfh487f34h8hiuw3")
.AuthenticateAdmin("admin", "adminpassword");
textBox1.AppendText("Connection successfull \n");
Application.DoEvents();
textBox1.AppendText("Looking for product with sku:" + "convertor-touchscreen \n");
Application.DoEvents();
var response = client.GetProductBySku("convertor-touchscreen").Result;
textBox1.AppendText("Done locating product \n");
Application.DoEvents();
...
}
起初我跑我的應用程序,它顯示後立即凍結「尋找與SKU產品......」
然後,我開始小提琴手,看看發生了什麼,和驚喜,我請求返回一個有效的迴應...我希望我的應用程序到一個新行添加到我的textBox ......但我的應用程序選擇凍結。
我textBox中包含該凍結之前:
連接全成尋找產品與 SKU:轉換器,觸摸屏
爲什麼響應再也回不來了我的應用程序?
所以這是我收到(按提琴手)中的TextView:
{
"10": {
"entity_id": "10",
"attribute_set_id": "4",
"type_id": "simple",
"sku": "convertor-touchscreen",
"name": "Convertor touchscreen",
"meta_title": null,
"meta_description": null,
"url_key": "convertor-touchscreen",
"custom_design": null,
"page_layout": null,
"options_container": "container1",
"country_of_manufacture": null,
"msrp_enabled": "2",
"msrp_display_actual_price_type": "4",
"gift_message_available": null,
"creareseo_discontinued": null,
"creareseo_discontinued_product": null,
"description": "Convertor touchscreen",
"short_description": "Convertor touchscreen",
"meta_keyword": null,
"custom_layout_update": null,
"price": "421.0000",
"special_price": "380.0000",
"weight": "0.1500",
"msrp": null,
"special_from_date": "2015-11-24 00:00:00",
"special_to_date": "2015-11-26 00:00:00",
"news_from_date": null,
"news_to_date": null,
"custom_design_from": null,
"custom_design_to": null,
"status": "1",
"visibility": "4",
"tax_class_id": "2",
"featured": "1"
}
}
所以有響應
爲什麼會出現這種凍結我的應用程序?我怎麼能通過這個,所以我可以以某種方式解釋它?
我希望能夠從出現到返回
「等待操作者只能異步方法中使用」 – user1137313
@ user1137313你標記與'async'修改你的方法,我在回答了什麼? –
非常感謝。我只是浪費在這:( – user1137313