小编Jed*_*Jed的帖子

Blazor UI 锁定

更新:它是从 json 到锁定线程的类的转换。我已经用较小的数据包尝试了相同的过程,并且 UI 没有冻结。所以问题是如何克服这个问题?

我试图从解析为类的 JSON 中获取值:

 public async Task<BitcoinDetails> GetData()
    {

        return await _httpClient.GetFromJsonAsync<BitcoinDetails>("https://localhost:5001/proxy");

    }
Run Code Online (Sandbox Code Playgroud)

我使用 OnInitializedAsync 将数据加载到视图中,但是以下代码锁定了 UI

_bitcoinDetails = new BitcoinDetails();
        _bitcoinDetails = await _bitcoinApiService.GetData();

        var price = _bitcoinDetails.data.Find(x => x.symbol == "BTC");
        if (price == null)
        {
            _bitcoinPrice = 0;
        }

        _bitcoinPrice = double.Parse(price.quote.USD.price.ToString());
Run Code Online (Sandbox Code Playgroud)

如何重构此代码以在不锁定 UI 的情况下加载数据?

查看代码:

 @if (_bitcoinDetails == null)
{
    <p><em>Loading...</em></p>
}
else
{
<h3>BTC:@_bitcoinPrice</h3>
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core blazor

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

在 Asp Mvc 上使用 OWIN 自定义身份验证

我正在尝试在 Asp MVC 上使用 owin 创建登录屏幕。这是控制器中的代码。

我什至尝试对这些值进行硬编码,但在登录后尝试进入仪表板时仍然得到 401。

 [HttpPost]
    public ActionResult Login(string username, string password)
    {
        int userId = 0;
        string role = string.Empty;

        if (new UserManager().IsValid(username, password, ref userId, ref role))
        {
            var ident = new ClaimsIdentity(
              new[] { 
          // adding following 2 claim just for supporting default antiforgery provider
          new Claim(ClaimTypes.NameIdentifier, userId.ToString()),
          new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"),

          new Claim(ClaimTypes.Name,username),

          // optionally you could add roles if any
          new Claim(ClaimTypes.Role, role)

              },
              DefaultAuthenticationTypes.ApplicationCookie);

            HttpContext.GetOwinContext().Authentication.SignIn(
               new AuthenticationProperties { IsPersistent = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc owin

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

用php在后台执行shell脚本

我需要执行一个shell脚本.抓住我想做到这一点

$Command = "nohup cvlc input --sout '#transcode {vcodec=h264,acodec=mp3,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8083/".output"}' &";
$str = shell_exec($Command);
Run Code Online (Sandbox Code Playgroud)

我不希望它等到命令完成,我希望它在后台进程中运行.我不想要另一个php线程因为它会超时命令最多可能需要3个小时才能完成.

php linux shell

4
推荐指数
2
解决办法
1万
查看次数

使用未声明的标识符'UIUserNotificationSettings'

我正在尝试使用Xcode 6编译现有的应用程序.

这是我的代码:

UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

use of undeclared identifier 'UIUserNotificationSettings'
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题.

这是我对iOS 8的检查:

if (SYSTEM_VERSION_LESS_THAN(_iOS_8_0)) {

        // Displaying notifications and ringing

        if ([self isMissingMandatoryNotificationTypes:[UIApplication.sharedApplication enabledRemoteNotificationTypes]]) {

            [self registrationWithSuccess:^{
                DDLogInfo(@"Push notifications were succesfully re-enabled");
            } failure:^{
                [self.missingPermissionsAlertView show];
            }];
        }

    } else {

        // UIUserNotificationsSettings
        UIUserNotificationSettings *settings = [UIApplication.sharedApplication currentUserNotificationSettings];
Run Code Online (Sandbox Code Playgroud)

objective-c ios ios8

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

将param传递给java android类

这是我要去的班级

public class AxxessCCPAccountDetails extends Activity {

public AxxessCCPAccountDetails(String username) {

}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.accountdetails);
}
Run Code Online (Sandbox Code Playgroud)

}

这是我传递的代码

lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {
        // When clicked, show a toast with the TextView text
        Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
            Toast.LENGTH_SHORT).show();

        Intent myIntent = new Intent(view.getContext(), AxxessCCPAccountList.class);
        startActivityForResult(myIntent, 0);
      }
    });
Run Code Online (Sandbox Code Playgroud)

我需要将用户名传递给一个类.我如何将该参数传递给该类,然后激活链接到视图的活动(类).

谢谢

java android constructor

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

循环nodejs中的setInterval

我知道还有其他问题,但我的代码似乎没有用.你能看看我的代码并告诉我哪里错了.

 var mysql = require('mysql');

var client = mysql.createClient({
  user: 'jed',
  password: 'jed8703',
  host: 'localhost',
  database: 'jedtest'
});

//var query = client.query(
//  'INSERT INTO testtable '+
//  'SET testid = ?, name = ?, value = ?',
//  [1, 'test', 'test']
//);


client.query(
  'SELECT * FROM testtable',
  function selectCb(err, results, fields) {
    if (err) {
      throw err;
    }

    console.log(results[0].Name);
    for(var i in results)
        {
            (function(y)
            {
                setInterval(function() {
                  console.log(results[y].Name + 'value:' + results[y].Value );
                }, 5000 );
            })
        } …
Run Code Online (Sandbox Code Playgroud)

javascript loops node.js

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