小编Lin*_*nky的帖子

什么是AppDomain?

什么是AppDomain?AppDomains的好处是什么?为什么微软带来了AppDomains的概念,没有AppDomains会出现什么问题?

请详细说明.

.net c# appdomain

131
推荐指数
3
解决办法
8万
查看次数

.Net Async ContinueWith VS在任务中嵌入任务

只是想知道异步时最好的方法.起初我的代码看起来像这样(示例简化了).

public NotificationSummary SendNotification()
{
      var response = new NotificationSummary();
      var first = FindSubscriptions(1);
      ... 
      var seventh = FindSubscriptions(7);

      Task.WaitAll(first, ... , seventh);

      response.First = first.Result;
      ...
      response.Seventh = seventh.Result;
      return response;
}


private Task<NotificationResult> FindSubscriptions(int day)
{
     return Task.Run(() => 
     {
        var subscriptions = // call to database to get list of subscriptions
        var tasks = subscriptions.Select(x =>  SendOutNotification(x))
        var results = Task.WhenAll(tasks).Result.ToList();
        return // map results to NotificationResult
     }
}


private Task<IndividualResult> SendOutNotification(Subscription subscription)
{
    return Task.Run(() => …
Run Code Online (Sandbox Code Playgroud)

.net c# asynchronous task async-await

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

ODP.NET:参数类型“缓存”在相同的 CommandText 上

我目前正在评估 Oracle 的 ODP.NET DataProvider,遇到了一个测试用例中出现的问题:当使用不同的参数类型执行相同的命令文本时,第一个执行的命令的参数类型将用于以下所有命令命令。

以下面的代码为例:

const int sampleInt32 = 1234567890;
const string sampleNvarchar = "someTestString";

const string sqlCommandtext = "SELECT :PARAM PARAM FROM DUAL";
using (OracleConnection connection = new OracleConnection(builder.ConnectionString))
{
    connection.Open();

    //Test 1 - Int 32
    using (OracleCommand commandInt32 = connection.CreateCommand())
    {
        commandInt32.CommandText = sqlCommandtext;
        commandInt32.Parameters.Add("PARAM", OracleDbType.Int32, sampleInt32, ParameterDirection.Input);
        using (IDataReader reader = commandInt32.ExecuteReader())
        {
            while (reader.Read())
            {
                int resultInt32 = (int)reader.GetDecimal(0);
                Assert.AreEqual(sampleInt32, resultInt32);
            }
        }
    }
    //Test 2 - NVarchar
    using (OracleCommand commandNVarchar = connection.CreateCommand())
    {
        commandNVarchar.CommandText …
Run Code Online (Sandbox Code Playgroud)

c# ado.net odp.net

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

标签 统计

c# ×3

.net ×2

ado.net ×1

appdomain ×1

async-await ×1

asynchronous ×1

odp.net ×1

task ×1