小编Anh*_*ran的帖子

从Task.Run异步更新进度条

我有一种从用户信息生成软件激活密钥的方法:

private async void GenerateAsync()
        {
            await Task.Run(() =>
            {
                var secretstring = "CustomerName >> " + txtFullname.Text + " >> " + txtproducid.Text;
                keymng = new KeyManager(secretstring);
                var dateexp = numExpdate.Value;
                if (dateexp == 0)
                {
                    dateexp = 730000;
                }

                if (cbLicenseType.SelectedIndex == 0)
                {
                    kvc = new KeyValueClass()
                    {
                        LicenseType = LicenseType.FULL,
                        Header = Convert.ToByte(9),
                        Footer = Convert.ToByte(6),
                        ProductCode = PRODUCTCODE,
                        Edition = (Edition)Enum.Parse(typeof(Edition), cbEdition.SelectedText),
                        Version = 1,
                        Expiration = DateTime.Now.AddDays(Convert.ToInt32(dateexp))
                    };

                    if (!keymng.GenerateKey(kvc, ref productkey))
                    {
                        //Handling …
Run Code Online (Sandbox Code Playgroud)

c# asynchronous winforms async-await

2
推荐指数
2
解决办法
7103
查看次数

在JSON.NET中解析JSON数组

我在REST API响应中有JSON对象:

{
    Result:
    [
        {
            "id": 1,
            "id_endpoint": 1,
            "name": "Endpoint 1",
            "description": "Endpoint 1",
            "unit": "mmol",
            "minthreshold": 30,
            "maxthreshold": -15,
            "id_device": 4,
            "value": 7,
            "time": "2016-12-24T21:20:19.000Z",
            "address": "Endpoint 1",
            "id_user": 1
        }, {
            "id": 2,
            "id_endpoint": 1,
            "name": "Endpoint 1",
            "description": "Endpoint 1",
            "unit": "mmol",
            "minthreshold": 30,
            "maxthreshold": -15,
            "id_device": 4,
            "value": 6,
            "time": "2016-12-24T21:20:16.000Z",
            "address": "Endpoint 1",
            "id_user": 1
        }, {
            "id": 3,
            "id_endpoint": 1,
            "name": "Endpoint 1",
            "description": "Endpoint 1",
            "unit": "mmol",
            "minthreshold": 30,
            "maxthreshold": -15, …
Run Code Online (Sandbox Code Playgroud)

c# json json.net

1
推荐指数
1
解决办法
443
查看次数

标签 统计

c# ×2

async-await ×1

asynchronous ×1

json ×1

json.net ×1

winforms ×1