小编Mad*_*kor的帖子

使用TPL的Parallel.ForEach时跟踪进度

以下是跟踪进度的最佳方法

long total = Products.LongCount();
long current = 0;
double Progress = 0.0;

Parallel.ForEach(Products, product =>
{
    try
    {
        var price = GetPrice(SystemAccount, product);
        SavePrice(product,price);
    }
    finally
    {
        Interlocked.Decrement(ref this.current);
    }});
Run Code Online (Sandbox Code Playgroud)

我想将进度变量从0.0更新为1.0(当前/总)但我不想使用会对并行性产生负面影响的任何内容.

c# multithreading plinq task-parallel-library c#-4.0

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

使用 struct & mongodb/mongo-go-driver 更新/替换 mongodb 文档

我正在尝试使用结构更新/替换 mongodb 文档,但我一直在获取 err: update document must contain key beginning with '$'

collection := r.client.Database(database).Collection(greetingCollection)
payment.MongoID = objectid.New()
filter := bson.NewDocument(bson.EC.String("id", payment.ID))
_, err := collection.UpdateOne(ctx, filter, payment)
return err
Run Code Online (Sandbox Code Playgroud)

go mongodb mongodb-query

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

如何使用Homebrew在OSX上安装DNX?

您好,因为k重命名为dnx我不知道如何在我的mac上安装这些工具?

dev分支上的文档尚未更新以反映重命名

https://github.com/aspnet/Home/tree/dev

dnx asp.net-core

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

Identity Server 4 在 docker 容器中运行异常:无法加载 DLL 'System.Security.Cryptography.Native.OpenSsl'

我试图让 Identity Server 4 在 docker 容器中与 ASP.NET Core 一起运行,但我不断收到以下异常

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Crypto' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native.OpenSsl': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Interop.Crypto.GetMaxMdSize()
   at Interop.Crypto..cctor()
   --- End of inner exception stack trace ---
   at Interop.Crypto.GetRandomBytes(Byte[] buf, Int32 num)
   at System.Security.Cryptography.RNGCryptoServiceProvider.GetBytes(Byte[] data)
   at IdentityModel.CryptoRandom.CreateUniqueId(Int32 length)
   at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderExtensions.SetTemporarySigningCredential(IIdentityServerBuilder builder)
   at Microsoft.Extensions.DependencyInjection.IdentityServerServiceCollectionExtensions.AddDeveloperIdentityServer(IServiceCollection services) …
Run Code Online (Sandbox Code Playgroud)

c# docker .net-core asp.net-core identityserver4

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

无法从 Jenksinfile 中安装 ansible-galaxy 角色来使用 (git)scm 引用的角色构建和部署基础设施

我有以下詹金斯文件

pipeline {
    agent {
        dockerfile {
            args "-u root -v /var/run/docker.sock:/var/run/docker.sock"
        }
    }
    environment {
        ESXI_CREDS = credentials('ESXI_CREDS')
        PACKER_LOG = 1
    }
    stages {
        stage('Build Base image') {
            steps {
               sh "ansible-galaxy install -r ./requirements.yml"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

参考.yml

- src:     
  ssh://tfsserver/_git/ansible-sshd
  scm: git
  name: ansible-sshd
Run Code Online (Sandbox Code Playgroud)

它使用以下 Dockerfile

FROM hashicorp/packer:full

RUN apk --no-cache add git openssh-client rsync jq py2-pip py-boto py2-six py2-cryptography py2-bcrypt py2-asn1crypto py2-jsonschema py2-pynacl py2-asn1 py2-markupsafe py2-paramiko py2-dateutil py2-docutils py2-futures py2-rsa py2-libxml2 libxml2 libxslt && \
    apk …
Run Code Online (Sandbox Code Playgroud)

tfs ansible docker ansible-galaxy jenkins-pipeline

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

使用Thinktecture.IdentityServer3作为联合提供程序,转换声明

你好我一直试图找出如何配置IdentityServer3成为一个多租户联合提供商,可以转换和丰富从ADSF,Google +,Microsoft帐户返回的索赔.

有没有人有任何试图执行以下操作的示例代码?

MyWebApp(multi-tenant) <-- IdSrv3 <---- ADFS
                            ^
                            |<------- Google+
                            |<------- Microsoft Account
                            |<------- Facebook Account
Run Code Online (Sandbox Code Playgroud)

federated-identity claims-based-identity thinktecture-ident-server

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

你如何重新运行dnx.任何文件更改的kestrel命令?

每当更改任何文件时,如何执行我的kestrel服务器以重新启动?而不只是停止?

我试过了

dnx --watch . kestrel
Run Code Online (Sandbox Code Playgroud)

但服务器只是停止,我必须手动重新运行该命令

我也尝试过使用npm watch命令,但这似乎只是绊倒了

watch 'dnx --watch . kestrel' .
Run Code Online (Sandbox Code Playgroud)

dnx asp.net-core

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