我一直在阅读很多关于线程的内容,但无法弄清楚如何找到我的问题的解决方案.首先让我介绍一下这个问题.我有需要处理的文件.主机名和文件路径位于两个数组中.
现在我想设置几个线程来处理文件.要创建的线程数基于三个因素:
A)最大线程数不能超过所有方案中唯一主机名的数量.
B)必须按顺序处理具有相同主机名的文件.IE我们无法同时处理host1 _file1和host1 _file2.(数据完整性将受到威胁,这超出了我的控制范围
.C)用户可以限制可用于处理的线程数.线程数仍受上述条件A的限制.这纯粹是因为如果我们有大量的主机让我们说50 ..我们可能不希望同时处理50个线程.
在上面的示例中,最多可以创建6个线程.
最佳处理程序如下所示.
public class file_prep_obj
{
public string[] file_paths;
public string[] hostname;
public Dictionary<string, int> my_dictionary;
public void get_files()
{
hostname = new string[]{ "host1", "host1", "host1", "host2", "host2", "host3", "host4","host4","host5","host6" };
file_paths=new string[]{"C:\\host1_file1","C:\\host1_file2","C:\\host1_file3","C:\\host2_file1","C:\\host2_file2","C:\\host2_file2",
"C:\\host3_file1","C:\\host4_file1","C:\\host4_file2","C:\\host5_file1","C:\\host6_file1"};
//The dictionary provides a count on the number of files that need to be processed for a particular host.
my_dictionary = hostname.GroupBy(x => x)
.ToDictionary(g => g.Key,
g => g.Count());
} …
Run Code Online (Sandbox Code Playgroud) 我目前有以下MVC代码.
<li>@Html.ActionLink("Home", "Index", "Home")</li>
Run Code Online (Sandbox Code Playgroud)
这会生成以下HTML代码
<li>
<a href="/"></a>
</li>
Run Code Online (Sandbox Code Playgroud)
我如何获得以下HTML代码?
<a href="#">
<i class="icon-home icon-white"></i>
Home
</a>
Run Code Online (Sandbox Code Playgroud) 我面临着一个典型的Microsoft错误,我无法安装Windows Azure Active Directory模块,这里是Windows Azure AD for Powershell
背景:
我正在运行带有Service Pack 1的Windows 7.
目前已安装Powershell 4.0.
Microsoft.Net框架3.5.1是根据计划检查和特点
微软在线服务登录助手Beta版都和非Beta版是installed..PC重新启动,并与其中一方没有运气.
我在网上看过很多帖子,但似乎都没有帮助过.有谁知道如何克服这个烦人的bug.
我有以下类定义.
public class people
{
public string first_name { get; set; }
public string last_name { get; set; }
public DateTime date_of_birth { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了一系列人,如下所示:
people[] the_people = new people[3];
the_people[0].first_name="Tony";
the_people[0].last_name="Carrot";
the_people[0].date_of_birth=new DateTime(1959-03-16);
the_people[1].first_name="Joe";
the_people[1].last_name="Tomato";
the_people[1].date_of_birth=new DateTime(1963-06-2);
the_people[2].first_name="Tarina";
the_people[2].last_name="Wends";
the_people[2].date_of_birth=new DateTime(1982-11-22);
Run Code Online (Sandbox Code Playgroud)
如何将the_people对象的first_names存储在新的字符串数组中,以便获得如下所示的输出.这可能通过linq
string[] the_peoples_first_names=new string[3] {"Tony","Joe","Tarina"};
Run Code Online (Sandbox Code Playgroud)
类似地,我如何获得一个日期时间数组,以便将所有人的出生日期存储在单独的DateTime数组中.
c# ×2
arrays ×1
asp.net-mvc ×1
async-await ×1
azure ×1
class ×1
html ×1
object ×1
powershell ×1
razor ×1
task ×1
windows ×1