<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>专业技术 Archives | Xiaoming Tu - Blog</title>
	<atom:link href="https://www.xiaomingtu.com/categories/professional/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xiaomingtu.com/categories/professional</link>
	<description>学习、工作、生活，点点滴滴。</description>
	<lastBuildDate>Sun, 23 Oct 2016 23:02:12 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>How to resolve deadlock in asynchronization code with async/await</title>
		<link>https://www.xiaomingtu.com/archives/15737?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=resolve-deadlock-asynchronization-code-asyncawait</link>
					<comments>https://www.xiaomingtu.com/archives/15737#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Sun, 16 Oct 2016 23:10:51 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[async]]></category>
		<category><![CDATA[await]]></category>
		<category><![CDATA[deadlock]]></category>
		<category><![CDATA[task]]></category>
		<category><![CDATA[unit tests]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">http://xiaomingtu.com/?p=15737</guid>

					<description><![CDATA[<p>Background In .NET, there are currently three main asynchronous programming models: Asynchronous Programming Model (APM), Event-based Asynchronous Pattern (EAP) and Task-based Asynchronous Pattern (TAP). The TAP is the latest technology that is based on the Task and Task&#60;T&#62; types (available since .NET 4.0) in the System.Threading.Tasks namespace. Programmers can also use async/await keywords to improve the code [&#8230;]</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15737">How to resolve deadlock in asynchronization code with async/await</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Background</h2>
<p>In .NET, there are currently three main asynchronous programming models: <strong>Asynchronous Programming Model (APM)</strong>, <strong>Event-based Asynchronous Pattern (EAP)</strong> and <strong>Task-based Asynchronous Pattern (TAP)</strong>. The TAP is the latest technology that is based on the Task and Task&lt;T&gt; types (available since .NET 4.0) in the System.Threading.Tasks namespace. Programmers can also use async/await keywords to improve the code readability since C# 5.0. There is a <a href="https://msdn.microsoft.com/en-us/library/hh873178(v=vs.110).aspx" target="_blank">MSDN article</a> explaining on the interop of the TAP model with previous asynchronous models. When programming in an asynchronous way, programmers need to be very careful of the deadlock. In this post, a common deadlock issue in TAP is explained and solutions are provided to avoid it in both production code and unit tests.</p>
<h2>Problem</h2>
<p>Here is the code-behind of a form. There is a button named <em>button1</em> and a text box named <em>textbox1</em> on the form. When the button is clicked, it runs a long time job that is sleeping for 2 seconds and shows a message in the text box then.</p><pre class="urvanov-syntax-highlighter-plain-tag">public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        InvokeTask();
    }

    public void InvokeTask()
    {
        textBox1.Text = $"Start task at {DateTime.Now.ToString("T")} and wait";

        var task = DoLongTimeJob();
        task.Wait();

        textBox1.Text = $"Task finished at {DateTime.Now.ToString("T")}";
    }

    public static async Task DoLongTimeJob()
    {
        await Task.Delay(TimeSpan.FromSeconds(2));
    }
}</pre><p><span id="more-15737"></span></p>
<h2>Investigation</h2>
<p>As we all know, Windows applications is based on a single-threaded model. A message pump runs on the main thread which listens and dispatches messages to the different listeners. The above code run into a deadlock because of this. How does it happen?</p>
<p>On line 18, the main UI thread waits for the task to complete here. On line 25, the code were put on a different thread to run which just sleep for 2 seconds. After that, it tries to return back to the main UI thread. The reason is that the default behaviour of the &#8216;<em>await</em>&#8216;  keyword will let the code after it to run in the original synchronization context. You can think of the synchronization context as a thread. If you click the button, <strong>the deadlock happens because the main UI thread is waiting for the task to complete and the awaiter (line 25) is waiting for the main UI thread to be available for running the remaining code.</strong> Although there is no &#8216;visible&#8217; code after &#8216;<em>await</em>&#8216;, the awaiter still needs to let the function finish.</p>
<h2>Resolve in Production Code</h2>
<p>You may have not noticed this deadlock in the past because it is quite common to use the &#8216;async void&#8217; event handler instead of a normal event handler when using TAP in WinForm applications. The code usually look like the following. Note the usage of <em>async</em>/<em>await</em> in both &#8216;button1_Click&#8217; and &#8216;InvokeTask&#8217; method.</p><pre class="urvanov-syntax-highlighter-plain-tag">public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private async void button1_Click(object sender, EventArgs e)
    {
        await InvokeTask();
    }

    public async Task InvokeTask()
    {
        textBox1.Text = $"Start task at {DateTime.Now.ToString("T")} and wait";

        await DoLongTimeJob();

        textBox1.Text = $"Task finished at {DateTime.Now.ToString("T")}";
    }

    public static async Task DoLongTimeJob()
    {
        await Task.Delay(TimeSpan.FromSeconds(2));
    }
}</pre><p>The magic here is the &#8216;async void&#8217; event handler. It is called differently by the runtime because it <em>returns (not completed yet)</em> immediately when it reaches the first &#8216;await&#8217; in its function body [<a href="http://stackoverflow.com/a/27228597/1671263" target="_blank">SO answer</a>]. So, in production code, you should try to use async/await all the way &#8216;up&#8217; to the event handlers or controllers&#8217; actions if in a ASP.NET application.</p>
<h2>Problem In Unit Tests</h2>
<p>What about unit testing the DoLongTimeJob method? In NUnit, the following methods code could be used to this method.</p><pre class="urvanov-syntax-highlighter-plain-tag">[Test]
public void TestWithWait()
{
    // Act
    var task = Form1.DoLongTimeJob();
    task.Wait();

    // Assert
    Assert.That(task.IsCompleted, Is.True);
}

[Test]
public async Task TestWithAwait()
{
    // Act
    await Form1.DoLongTimeJob();

    // Can assert on the return value if the task has results.
}</pre><p>This two tests runs absolutely fine if they run solely but, both of them can&#8217;t finish when they run with the following test together. (Note the following test runs before above ones).</p><pre class="urvanov-syntax-highlighter-plain-tag">[Test]
public void TestRunFirst()
{
    var newTitle = "form title";
    using (var form = new Form1())
    {
        form.Text = newTitle;

        Assert.That(form.Text, Is.EqualTo(newTitle));
    }
}</pre><p>Why does this happen? If we put a break point  at the beginning of the <em>TestWithWait</em> method (line 3 of Code Sample 3), run the test solely and run the test with <em>TestRunFirst</em>. Have a look at the SynchronizationContext.Current and here are the difference. When it runs solely, the SynchronizationContext.Current is <strong>null</strong>.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-15743" src="http://xiaomingtu.com/wp-content/uploads/2016/10/Solely-300x111.jpg" alt="TestWithWait runs solely" width="522" height="193" srcset="https://www.xiaomingtu.com/wp-content/uploads/2016/10/Solely-300x111.jpg 300w, https://www.xiaomingtu.com/wp-content/uploads/2016/10/Solely-768x285.jpg 768w, https://www.xiaomingtu.com/wp-content/uploads/2016/10/Solely.jpg 846w" sizes="(max-width: 522px) 100vw, 522px" /></p>
<p>However, when it runs with <em>TestRunFirst</em>, the value of SynchronizationContext.Current is an instance of the <strong>WindowsFormsSynchronizationContext</strong>.</p>
<p><img decoding="async" class="alignnone wp-image-15744" src="http://xiaomingtu.com/wp-content/uploads/2016/10/WithTestRunFirst-300x106.jpg" alt="TestWithWait runs with UI test" width="521" height="184" srcset="https://www.xiaomingtu.com/wp-content/uploads/2016/10/WithTestRunFirst-300x106.jpg 300w, https://www.xiaomingtu.com/wp-content/uploads/2016/10/WithTestRunFirst-768x272.jpg 768w, https://www.xiaomingtu.com/wp-content/uploads/2016/10/WithTestRunFirst.jpg 886w" sizes="(max-width: 521px) 100vw, 521px" /></p>
<p>As you could remember, the test is running in the same way as in the normal event handler (not the &#8216;async void&#8217; event handler).</p>
<p>Why does the SynchronizationContext.Current change? In WinForm applications, whenever a UI control is created, the current synchronization context will be changed to an instance of the WindowsFormssynchronizationContext. This can be simply validated by putting a break point in the Program.cs just before the form is created. You can see the synchronization context changed from <em>null</em> to <em>WindowsFormssynchronizationContext</em>.</p>
<h2>Resove in Unit Tests</h2>
<p>There are several ways to avoid the deadlock as long as you know the reason. The first method is to run the task on a different thread other than the current thread. (Please note that I have changed to use thread instead of synchronization context for the sake of simplicity.) This can be done by calling Task.Run method which will run the task on a thread from the thread pool.</p><pre class="urvanov-syntax-highlighter-plain-tag">[Test]
public void When_DoLongTimeJob_Called_Then_Task_Can_Be_Completed()
{
    // Act
    var task = Task.Run(async () =&gt; await Form1.DoLongTimeJob());

    // Assert
    Assert.That(task.IsCompleted, Is.True);
}</pre><p>The second method is to change the behaviour of the DoLongTimeJob method. Let it run the subsequent code on a different thread instead of entering to the original thread. The <a href="https://msdn.microsoft.com/en-us/library/system.threading.tasks.task.configureawait(v=vs.110).aspx" target="_blank">Task.ConfigureAwait(bool) </a>method allows you to do this. The method will be looked like the following.</p><pre class="urvanov-syntax-highlighter-plain-tag">public static async Task DoLongTimeJob()
{
    await Task.Delay(TimeSpan.FromSeconds(2)).ConfigureAwait(false);
}</pre><p>Passing a <em>false</em> to the <em>ConfigureAwait</em> method. It tells the awaiter to not capture the original context and continue the execution on a different thread. It is <a href="http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html" target="_blank">recommended to be a good practice</a> to always call <em>ConfigureAwait(false)</em> on every &#8216;await&#8217; EXCEPT the remaining code after &#8216;await&#8217; must be run on the original thread. For example in the InvokeTask method as shown in Code Sample 1, line 20 needs to access the UI control, so it must be run on the original thread which is the main UI thread. Note that every async methods are independent. Configuring the awaiter only affects the current &#8216;async&#8217; method.</p>
<p>NOTE! If you want to use this method to solve the second test in Code Sample 3, you must append ConfigureAwait(false) at the end of 
			<span id="urvanov-syntax-highlighter-6ada8beb10d62104654018" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-r">await</span><span class="crayon-h"> </span><span class="crayon-v">Form1</span><span class="crayon-sy">.</span><span class="crayon-e">DoLongTimeJob</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span></span></span> , otherwise the test still gets blocked because the execution tries to go back to the original thread which is created in WindowsFormsSynchronizationContext as well.</p>
<p>The last method is to explicitly clear the SynchronizationContext when running your tests. This can be done in the SetUp method before every tests are run. The current synchronization context is cleared so that it does affect the current test.</p><pre class="urvanov-syntax-highlighter-plain-tag">[SetUp]
public void Setup()
{
    SynchronizationContext.SetSynchronizationContext(null);
}</pre><p></p>
<h2>Conclusion</h2>
<p>Any of the above methods can help you avoiding the deadlock in unit tests. Personally, I prefer to apply ConfigureAwait as much as possible because, when you create an async method, you are delegating work on a different thread and have less interests on the state of the current thread. In the unit tests, either the first method or the third method works. The third method is preferable as it does not slow the tests because of the resource allocations for additional tasks.</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15737">How to resolve deadlock in asynchronization code with async/await</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15737/feed</wfw:commentRss>
			<slash:comments>272</slash:comments>
		
		
			</item>
		<item>
		<title>.NET中检测当前程序为32位/64位以及调整</title>
		<link>https://www.xiaomingtu.com/archives/15681?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=net%25e4%25b8%25ad%25e9%2580%259a%25e8%25bf%2587%25e4%25bb%25a3%25e7%25a0%2581%25e5%2588%25a4%25e6%2596%25ad%25e5%25bd%2593%25e5%2589%258d%25e7%25a8%258b%25e5%25ba%258f%25e8%25bf%2590%25e8%25a1%258c%25e5%259c%25a832%25e4%25bd%258d64%25e4%25bd%258d%25e7%258e%25af%25e5%25a2%2583</link>
					<comments>https://www.xiaomingtu.com/archives/15681#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Wed, 23 Apr 2014 22:33:31 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[开发语言]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[有图有真相]]></category>
		<category><![CDATA[桌面应用]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15681</guid>

					<description><![CDATA[<p>熟悉.NET开发的人都知道，在使用Visual Studio创建项目的时候，默认使用的编译配置选项为Any CPU，这意味着程序在32位机器上将使用32位进程；而在64位机器上将会自动运行在64位进程中。这也是.NET的强大之处，以最简单的方式同时支持32位以及64位系统，并且充分利用64位系统的优势。 那么，我们如何在代码中判断当前的程序正运行在32位还是64位进程中呢？最简单的方法就是通过： [crayon-6ada8beb1122d115327462/] 需要注意的是，上面提供的只是判断进程是否为32位或者64位，而不是当前系统是32位或64位。32位的程序是可以运行在64位的系统中的。 如果您已经编译好了程序为AnyCPU，希望在不重新编译的前提下修改程序的目标平台，可以通过corflags.exe工具来实现。 corflags用于查看程序的PE头信息，如下面的截图所示： 将一个目标平台为AnyCPU的程序改为目标平台是x86，则可以通过下面的方法： [crayon-6ada8beb11230337637202/] 下面几个链接也许有所帮助： http://blogs.msdn.com/b/joshwil/archive/2005/04/08/406567.aspx http://msdn.microsoft.com/en-us/library/ms973190.aspx &#8212; 本文结束</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15681">.NET中检测当前程序为32位/64位以及调整</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>熟悉.NET开发的人都知道，在使用Visual Studio创建项目的时候，默认使用的编译配置选项为Any CPU，这意味着程序在32位机器上将使用32位进程；而在64位机器上将会自动运行在64位进程中。这也是.NET的强大之处，以最简单的方式同时支持32位以及64位系统，并且充分利用64位系统的优势。</p>
<p>那么，我们如何在代码中判断当前的程序正运行在32位还是64位进程中呢？最简单的方法就是通过：<span id="more-15681"></span></p><pre class="urvanov-syntax-highlighter-plain-tag">public static bool Is64bProcess() 
{ 
    return IntPtr.Size == 8;
}</pre><p>需要注意的是，上面提供的只是判断进程是否为32位或者64位，而不是当前系统是32位或64位。32位的程序是可以运行在64位的系统中的。</p>
<p>如果您已经编译好了程序为AnyCPU，希望在不重新编译的前提下修改程序的目标平台，可以通过corflags.exe工具来实现。</p>
<p>corflags用于查看程序的PE头信息，如下面的截图所示：</p>
<div id="attachment_15683" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2014/04/corflags.jpg"><img decoding="async" aria-describedby="caption-attachment-15683" class="size-medium wp-image-15683" src="https://www.xiaomingtu.com/wp-content/uploads/2014/04/corflags-300x108.jpg" alt="corflags.exe示例" width="300" height="108" srcset="https://www.xiaomingtu.com/wp-content/uploads/2014/04/corflags-300x108.jpg 300w, https://www.xiaomingtu.com/wp-content/uploads/2014/04/corflags.jpg 661w" sizes="(max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15683" class="wp-caption-text">corflags.exe示例</p></div>
<p>将一个目标平台为AnyCPU的程序改为目标平台是x86，则可以通过下面的方法：</p><pre class="urvanov-syntax-highlighter-plain-tag">conflags.exe WindowsApplication3.exe /32BITREG+</pre><p>下面几个链接也许有所帮助：</p>
<ul>
<li><a title="How do exes/dlls generated with the /platform:x switch interact?" href="http://blogs.msdn.com/b/joshwil/archive/2005/04/08/406567.aspx" target="_blank">http://blogs.msdn.com/b/joshwil/archive/2005/04/08/406567.aspx</a></li>
<li><a title="Migrating 32-bit Managed Code to 64-bit" href="http://msdn.microsoft.com/en-us/library/ms973190.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms973190.aspx</a></li>
</ul>
<p>&#8212; 本文结束</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15681">.NET中检测当前程序为32位/64位以及调整</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15681/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>如何让Windows 8默认启动到传统桌面</title>
		<link>https://www.xiaomingtu.com/archives/15670?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%25a6%2582%25e4%25bd%2595%25e8%25ae%25a9windows-8%25e9%25bb%2598%25e8%25ae%25a4%25e5%2590%25af%25e5%258a%25a8%25e5%2588%25b0%25e4%25bc%25a0%25e7%25bb%259f%25e6%25a1%258c%25e9%259d%25a2</link>
					<comments>https://www.xiaomingtu.com/archives/15670#respond</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Wed, 23 Apr 2014 20:29:15 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[有图有真相]]></category>
		<category><![CDATA[桌面应用]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows 8]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15670</guid>

					<description><![CDATA[<p>在Windows 8以及Windows 8.1中，系统启动之后将会默认进入的新的开始界面。这一设定一直被人嘲讽，大家都希望能够回到以前的方式，开机能够默认进入到桌面环境以及恢复以前的开始菜单功能。 之前有爆料说四月份的更新将会恢复新的开始菜单以及提供选项让电脑在开机之后进入传统桌面环境，泄露的全新开始菜单如下图的样子。 可惜的是，在上周释出的更新中，并没有包含上面这个全新的开始菜单，而仅仅提供了“开机默认进入桌面”的选项，可以通过下面的方式开启： 任务栏上右击 &#8211; 属性 &#8211; 导航 &#8211; 勾选如图所示的选项。 &#160; 据报道，新的开始菜单将会在今年八月份或者秋季放出，慢慢等吧。我个人不在意，因为自从Windows 7开始，很少使用开始菜单，习惯的操作方式是在按徽标键之后直接输入要搜索的内容，不需要鼠标操作，非常的快捷。至于按下徽标键之后出来的是传统的开始菜单还是新的开始界面，只要能让我直接输入搜索内容就可以。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15670">如何让Windows 8默认启动到传统桌面</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>在Windows 8以及Windows 8.1中，系统启动之后将会默认进入的新的开始界面。这一设定一直被人嘲讽，大家都希望能够回到以前的方式，开机能够默认进入到桌面环境以及恢复以前的开始菜单功能。</p>
<p>之前有爆料说四月份的更新将会恢复新的开始菜单以及提供选项让电脑在开机之后进入传统桌面环境，泄露的全新开始菜单如下图的样子。</p>
<div id="attachment_15677" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2014/04/windows8startmenu.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15677" class="size-medium wp-image-15677" src="https://www.xiaomingtu.com/wp-content/uploads/2014/04/windows8startmenu-300x199.jpg" alt="泄漏的Windows 8开始菜单" width="300" height="199" srcset="https://www.xiaomingtu.com/wp-content/uploads/2014/04/windows8startmenu-300x199.jpg 300w, https://www.xiaomingtu.com/wp-content/uploads/2014/04/windows8startmenu.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15677" class="wp-caption-text">泄漏的Windows 8开始菜单</p></div>
<p>可惜的是，在上周释出的更新中，并没有包含上面这个全新的开始菜单，而仅仅提供了“开机默认进入桌面”的选项，可以通过下面的方式开启：<span id="more-15670"></span></p>
<p><strong>任务栏上右击 &#8211; 属性 &#8211; 导航 &#8211; 勾选如图所示的选项。</strong></p>
<p>&nbsp;</p>
<div id="attachment_15676" style="width: 262px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2014/04/boot-to-desktop.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15676" class="size-medium wp-image-15676" src="https://www.xiaomingtu.com/wp-content/uploads/2014/04/boot-to-desktop-252x300.jpg" alt="boot-to-desktop" width="252" height="300" srcset="https://www.xiaomingtu.com/wp-content/uploads/2014/04/boot-to-desktop-252x300.jpg 252w, https://www.xiaomingtu.com/wp-content/uploads/2014/04/boot-to-desktop.jpg 414w" sizes="auto, (max-width: 252px) 100vw, 252px" /></a><p id="caption-attachment-15676" class="wp-caption-text">boot-to-desktop</p></div>
<p>据<a href="http://www.theverge.com/2014/4/23/5643328/windows-8-start-menu-return-in-second-update" target="_blank">报道</a>，新的开始菜单将会在今年八月份或者秋季放出，慢慢等吧。我个人不在意，因为自从Windows 7开始，很少使用开始菜单，习惯的操作方式是在按徽标键之后直接输入要搜索的内容，不需要鼠标操作，非常的快捷。至于按下徽标键之后出来的是传统的开始菜单还是新的开始界面，只要能让我直接输入搜索内容就可以。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15670">如何让Windows 8默认启动到传统桌面</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15670/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>关于Google关闭Google Reader</title>
		<link>https://www.xiaomingtu.com/archives/15623?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%2585%25b3%25e4%25ba%258egoogle%25e5%2585%25b3%25e9%2597%25adgoogle-reader</link>
					<comments>https://www.xiaomingtu.com/archives/15623#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Mon, 25 Mar 2013 21:17:17 +0000</pubDate>
				<category><![CDATA[Web应用]]></category>
		<category><![CDATA[专业技术]]></category>
		<category><![CDATA[人生感悟]]></category>
		<category><![CDATA[有图有真相]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[google keep]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[rss]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15623</guid>

					<description><![CDATA[<p>每天都习惯性的打开Google Reader看些新闻什么的，那天打开时看到了弹窗“Google Reader将于2013年7月1日停止”服务。震惊+意外，如此好的产品居然说关就关了！</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15623">关于Google关闭Google Reader</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>每天都习惯性的打开Google Reader看些新闻什么的，那天打开时看到了弹窗“Google Reader将于2013年7月1日停止”服务。震惊+意外，如此好的产品居然说关就关了！我从2008年开始用GReader，已经五年了，除了QQ之外，很难想到还有别的什么产品能让我用这么久的。</p>
<div id="attachment_15624" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2013/03/GReader.jpg" target="_blank"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15624" class="size-medium wp-image-15624 " alt="GReader统计" src="https://www.xiaomingtu.com/wp-content/uploads/2013/03/GReader-300x89.jpg" width="300" height="89" srcset="https://www.xiaomingtu.com/wp-content/uploads/2013/03/GReader-300x89.jpg 300w, https://www.xiaomingtu.com/wp-content/uploads/2013/03/GReader.jpg 1576w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15624" class="wp-caption-text">自08年第一次用GReader到现在为止的统计</p></div>
<p>GReader的强大之处有很多，最值得提到的有下面几点：</p>
<ol>
<li>所有订阅过的文章都有缓存，所以在GReader里面阅读不会受原始网站速度影响，只要你打开GReader快，那你打开所有的文章都一样快。</li>
<li>阅读之后文章缓存依然有效，以后也可以方便的查找，即使原始网站已经不存在。</li>
<li>使用HTTPS可以在兲朝无缝阅读任何资料，不需要怕墙。</li>
<li>异常便捷的快捷键，要是忘了的话，直接在键盘上按下“？”键，快捷键一目了然。</li>
<li>订阅任何的网站更新，即使网站没有输出RSS。（这个功能貌似早些时候已经移除）</li>
<li>其他RSS阅读器的基本功能就不用说了，肯定都有，而且更加简洁轻便。</li>
</ol>
<p>最近很多评论文章都说Google已经不再是以前的Google了。不得不说，这次这一举动真的伤害到了非常多的谷粉，也让广大谷粉对Google的信任度下降了许多。就比如最近新出的Google Keep，说实话，我第一次看到这个东西的时候觉得这又是一个很不错的想法，很实用。但是我想到了他们关闭GReader，万一开始用GKeep后，很多信息当记录在此，哪天突然关闭了怎么办？这真的让我犹豫了一下，以前用Google的产品从来不会有任何的顾虑。其实当年Google+出来之后，把GReader中的Share/Like功能替换掉时已经遭很多人唾弃，但至少其他功能都依旧。现在可好，整个都要关了。Google，你真的伤到我了！</p>
<p>前两天切换到Feedly试用了一下，虽然也是一个挺不错的产品，但是哪能跟Google这样财大气粗，服务器没法比。大量GReader涌入之后，他们赶忙各种升级，但是依然无法让我感到满意。我自从用GReader以来，从来没让我等待过，都是打开即阅读，而Feedly目前还无法做到。不过，他们的态度是非常值得称赞的，迅速的响应用户需求，提供无缝迁移、增加投入、加快新功能开发、让用户投票推选想要的功能以及他们的效率都不得不让任何一个人赞许。因此，等GReader关闭的时候，我相信Feedly将会是我不二的选择，希望到时候你也会喜欢。</p>
<p>最后，虽然希望很渺茫，但还是希望Google能将Google Reader保留下来。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15623">关于Google关闭Google Reader</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15623/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>用脚本批量删除文件</title>
		<link>https://www.xiaomingtu.com/archives/15617?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e7%2594%25a8%25e8%2584%259a%25e6%259c%25ac%25e6%2589%25b9%25e9%2587%258f%25e5%2588%25a0%25e9%2599%25a4%25e6%2596%2587%25e4%25bb%25b6</link>
					<comments>https://www.xiaomingtu.com/archives/15617#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Mon, 25 Mar 2013 12:41:23 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[桌面应用]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[vs2010]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15617</guid>

					<description><![CDATA[<p>使用脚本删除文件夹下的某个类型文件。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15617">用脚本批量删除文件</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>最近使用VS2010打开项目的时候会卡死，发现与恢复上一次打开的文档有关，只要把*.suo文件删除就能解决问题，所以有了下面的脚本：</p><pre class="urvanov-syntax-highlighter-plain-tag">FOR /F %%f IN ('DIR *.suo /B /AH') DO DEL /AH %%f</pre><p>关于这个脚本的说明：</p>
<ul>
<li>因为suo文件是隐藏的，所以在括号中如果直接使用 *.suo 的话讲找不到文件。</li>
<li>使用DIR命令的/B格式可以文件罗列出来，加上/AH开关之后只会查找隐藏文件。</li>
<li>FOR命令的/F开关可以将IN后面的集合按行分段，就能将DIR命令得到的文件列表逐行分开成多个文件了。</li>
<li>最后使用DEL命令将文件删除。</li>
</ul>
<p>我的机器只有在开机之后第一次用VS打开工程时才会卡死，后面即使有 *.suo 文件也不会。不知道是我的插件缘故还是VS的Bug，有经验的朋友欢迎留言指教。</p>
<p><strong>参考</strong></p>
<ul>
<li><a title="For命令语法参考" href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true" target="_blank">For命令语法</a></li>
</ul>
<p><strong>更行 2013年3月25日</strong></p>
<p>上面的脚本对于文件名中有空格的情况会有问题，建议使用下面的方式：</p><pre class="urvanov-syntax-highlighter-plain-tag">FOR /F "delims=?" %%f IN ('DIR /B /AH *.suo') DO (DEL "%%f")</pre><p>如果需要同时删除子文件夹中的文件，可以在DIR命令后面加上“/S”，如果想删除普通的文件而不是隐藏文件，只要把“/AH”删除即可。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15617">用脚本批量删除文件</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15617/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Windows 8中的输入法切换</title>
		<link>https://www.xiaomingtu.com/archives/15588?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=windows-8%25e4%25b8%25ad%25e7%259a%2584%25e8%25be%2593%25e5%2585%25a5%25e6%25b3%2595%25e5%2588%2587%25e6%258d%25a2</link>
					<comments>https://www.xiaomingtu.com/archives/15588#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Sun, 09 Sep 2012 20:30:44 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[有图有真相]]></category>
		<category><![CDATA[桌面应用]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows8]]></category>
		<category><![CDATA[语言]]></category>
		<category><![CDATA[输入法]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15588</guid>

					<description><![CDATA[<p>在Windows 8中，语言已经变成了比较自由、常用的选项。不同的输入法属于不同的语言下，比如我使用的系统是英语版的，在英语下无法添加中文的输入法，我必须添加一个简体中文的语言，然后在其下添加新的中文输入法，当需要切换输入法的时候，实际上是在切换语言。 在大部分时候，大家都不会碰到问题，但是如果你的键盘布局比较特殊，就会有影响，比如我的笔记本是英式键盘的，布局和国内电脑的键盘布局不一样。在以前的系统中，我都是使用简体中文一种输入语言，然后在其中除了使用一般的中文输入法之外，我还会添加英式键盘，这样我就能非常方便的切换（CTRL+SPACE），但是，在Win8中，你无法给简体中文添加英式键盘，这就导致了必须在英语语言下添加英式键盘。输入法切换也不方便，因为你得先切换语言，才能在某个语言下切换输入法。好在语言之间的切换有快捷键（WIN+SPACE）。这样我在两种语言下都只有一种输入方式的时候还是比较方便的，正如第一张图中看到的一样，我的英语语言下只有英式键盘一种输入方式，而简体中文中只有谷歌输入法，所以我现在要切换输入法的时候只要切换语言就能实现了。 这里还有一个问题，在Win8的默认设置下，当前语言是全局性的，也就是你切换到某个语言之后，所有程序中的输入方式都变成那个语言，这样带来的问题就是你得频繁的切换输入法。比如一边在网页里用英语写邮件，一边在QQ上用中文聊天，每次切换窗口都要换一下语言，虽然只是一次快捷键的时间，但还是很麻烦。解决办法就是在第二张图左边点击“Advance settings”，然后勾选“Let me set a different input method for each app window”，这样不同程序之间就不会共享语言选项了。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15588">Windows 8中的输入法切换</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>在Windows 8中，语言已经变成了比较自由、常用的选项。不同的输入法属于不同的语言下，比如我使用的系统是英语版的，在英语下无法添加中文的输入法，我必须添加一个简体中文的语言，然后在其下添加新的中文输入法，当需要切换输入法的时候，实际上是在切换语言。</p>
<div id="attachment_15589" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Switch-Language.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15589" class="size-medium wp-image-15589" title="切换语言" src="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Switch-Language-300x250.png" alt="切换语言" width="300" height="250" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Switch-Language-300x250.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/09/Switch-Language.png 312w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15589" class="wp-caption-text">任务栏中切换语言</p></div>
<div id="attachment_15590" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Language-Preferences.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15590" class="size-medium wp-image-15590" title="Win8中的语言选项" src="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Language-Preferences-300x177.png" alt="Win8中的语言选项" width="300" height="177" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Language-Preferences-300x177.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/09/Language-Preferences.png 933w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15590" class="wp-caption-text">Win8中的语言选项</p></div>
<p><span id="more-15588"></span>在大部分时候，大家都不会碰到问题，但是如果你的键盘布局比较特殊，就会有影响，比如我的笔记本是英式键盘的，布局和国内电脑的键盘布局不一样。在以前的系统中，我都是使用简体中文一种输入语言，然后在其中除了使用一般的中文输入法之外，我还会添加英式键盘，这样我就能非常方便的切换（CTRL+SPACE），但是，在Win8中，你无法给简体中文添加英式键盘，这就导致了必须在英语语言下添加英式键盘。输入法切换也不方便，因为你得先切换语言，才能在某个语言下切换输入法。好在语言之间的切换有快捷键（WIN+SPACE）。这样我在两种语言下都只有一种输入方式的时候还是比较方便的，正如第一张图中看到的一样，我的英语语言下只有英式键盘一种输入方式，而简体中文中只有谷歌输入法，所以我现在要切换输入法的时候只要切换语言就能实现了。</p>
<p>这里还有一个问题，在Win8的默认设置下，当前语言是全局性的，也就是你切换到某个语言之后，所有程序中的输入方式都变成那个语言，这样带来的问题就是你得频繁的切换输入法。比如一边在网页里用英语写邮件，一边在QQ上用中文聊天，每次切换窗口都要换一下语言，虽然只是一次快捷键的时间，但还是很麻烦。解决办法就是在第二张图左边点击“Advance settings”，然后勾选“Let me set a different input method for each app window”，这样不同程序之间就不会共享语言选项了。</p>
<div id="attachment_15592" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Advance-settings-for-language.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15592" class="size-medium wp-image-15592" title="语言中的高级设置" src="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Advance-settings-for-language-300x177.png" alt="语言中的高级设置" width="300" height="177" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Advance-settings-for-language-300x177.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/09/Advance-settings-for-language.png 933w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15592" class="wp-caption-text">勾选红色方框中的选项之后，可以为不同程序设置不同输入法</p></div>
<p>The post <a href="https://www.xiaomingtu.com/archives/15588">Windows 8中的输入法切换</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15588/feed</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>IE10哪儿去了？</title>
		<link>https://www.xiaomingtu.com/archives/15580?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ie10%25e5%2593%25aa%25e5%2584%25bf%25e5%258e%25bb%25e4%25ba%2586%25ef%25bc%259f</link>
					<comments>https://www.xiaomingtu.com/archives/15580#respond</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Sun, 09 Sep 2012 20:02:22 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[有图有真相]]></category>
		<category><![CDATA[桌面应用]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows8]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15580</guid>

					<description><![CDATA[<p>安装Win8之后，相信大家对IE10都印象非常深刻，完美的体现了Metro风格（现在该改口叫Windows 8风格了）。 但是在设置其他浏览器比如Chrome为默认浏览器之后，你就再也看不到Metro版的IE10了。这个可能和Win8里面App的概念有关。这时候，原先开始界面里的Chrome图标会有一些变化： 点击黑底这个图标将打开Metro版本的Chrome，虽然有些假。。。不过它确实是，而且这个Chrome和你在桌面上打开的Chrome并不是同一个。用过Chrome多用户功能的都知道，当切换到另外一个用户之后，Chrome就像是新的，所有内容（收藏栏、插件、设置等）都是独立的。这个Metro版的Chrome就类似这样，它和桌面上打开的Chrome并不是同一个。也就是说，你想让其他浏览器作为默认浏览器，而又想偶尔体验一下Metro风格的IE10，那是不可能的！除非将IE10改回默认浏览器。 如果你很幸运现在在用支持触摸屏的Win8的话，可能IE10会更加的适合你，因为结合其他的App一起使用，会非常的得心应手。如果你是像我一样的屌丝，还在用鼠标键盘的，那你只能暂时放弃Metro版的IE10了，因为你在使用桌面程序的时候，也会切换到Metro的IE中去。要知道在Win8里，传统桌面环境下的软件和Metro风格的App像是运行在两个环境中的，两者之间切换非常的不方便。我已经将默认安装的一些App都卸载了，因为大部分时候我还是习惯传统桌面风格，Metro程序更适合触摸屏使用，新版开始菜单对我来说和以前的开始菜单没区别，只是现在图标更大，点起来方便一些，而且搜索和以前一样，按“徽标”然后直接开始输入搜索内容就好了。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15580">IE10哪儿去了？</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>安装Win8之后，相信大家对IE10都印象非常深刻，完美的体现了Metro风格（现在该改口叫Windows 8风格了）。</p>
<p><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/09/IE10-Metro.png"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15581" title="Win8风格的IE10" src="https://www.xiaomingtu.com/wp-content/uploads/2012/09/IE10-Metro-300x168.png" alt="Win8风格的IE10" width="300" height="168" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/09/IE10-Metro-300x168.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/09/IE10-Metro.png 1920w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>但是在设置其他浏览器比如Chrome为默认浏览器之后，你就再也看不到Metro版的IE10了。这个可能和Win8里面App的概念有关。这时候，原先开始界面里的Chrome图标会有一些变化：<span id="more-15580"></span></p>
<div id="attachment_15582" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Browser-Icon-Compare.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15582" class="size-medium wp-image-15582" title="默认浏览器图标比较" src="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Browser-Icon-Compare-300x220.png" alt="默认浏览器图标比较" width="300" height="220" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Browser-Icon-Compare-300x220.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/09/Browser-Icon-Compare.png 576w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15582" class="wp-caption-text">默认浏览器不同的时候，开始界面图标不一样</p></div>
<p>点击黑底这个图标将打开Metro版本的Chrome，虽然有些假。。。不过它确实是，而且这个Chrome和你在桌面上打开的Chrome并不是同一个。用过Chrome多用户功能的都知道，当切换到另外一个用户之后，Chrome就像是新的，所有内容（收藏栏、插件、设置等）都是独立的。这个Metro版的Chrome就类似这样，它和桌面上打开的Chrome并不是同一个。也就是说，你想让其他浏览器作为默认浏览器，而又想偶尔体验一下Metro风格的IE10，那是不可能的！除非将IE10改回默认浏览器。</p>
<p>如果你很幸运现在在用支持触摸屏的Win8的话，可能IE10会更加的适合你，因为结合其他的App一起使用，会非常的得心应手。如果你是像我一样的屌丝，还在用鼠标键盘的，那你只能暂时放弃Metro版的IE10了，因为你在使用桌面程序的时候，也会切换到Metro的IE中去。要知道在Win8里，传统桌面环境下的软件和Metro风格的App像是运行在两个环境中的，两者之间切换非常的不方便。我已经将默认安装的一些App都卸载了，因为大部分时候我还是习惯传统桌面风格，Metro程序更适合触摸屏使用，新版开始菜单对我来说和以前的开始菜单没区别，只是现在图标更大，点起来方便一些，而且搜索和以前一样，按“徽标”然后直接开始输入搜索内容就好了。</p>
<div id="attachment_15583" style="width: 310px" class="wp-caption aligncenter"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Start.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-15583" class="size-medium wp-image-15583" title="开始界面" src="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Start-300x168.png" alt="开始界面" width="300" height="168" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/09/Start-300x168.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/09/Start.png 1920w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-15583" class="wp-caption-text">我现在的开始界面，清理的很干净，常用、开发、游戏都分开啦</p></div>
<p>The post <a href="https://www.xiaomingtu.com/archives/15580">IE10哪儿去了？</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15580/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Windows系统下给文件夹增加自定义右键菜单</title>
		<link>https://www.xiaomingtu.com/archives/15561?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=windows%25e7%25b3%25bb%25e7%25bb%259f%25e4%25b8%258b%25e7%25bb%2599%25e6%2596%2587%25e4%25bb%25b6%25e5%25a4%25b9%25e5%25a2%259e%25e5%258a%25a0%25e8%2587%25aa%25e5%25ae%259a%25e4%25b9%2589%25e5%258f%25b3%25e9%2594%25ae%25e8%258f%259c%25e5%258d%2595</link>
					<comments>https://www.xiaomingtu.com/archives/15561#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Fri, 31 Aug 2012 11:45:11 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[桌面应用]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows7]]></category>
		<category><![CDATA[windows8]]></category>
		<category><![CDATA[菜单]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15561</guid>

					<description><![CDATA[<p>对于开发人员来说，经常需要使用命令行并且切换到某个指定的目录中去。可以通过给文件夹增加一个右键菜单（比如Open in CMD）来完成。 只要在注册表中增加下面的键值就能完成： 在HKLM\SOFTWARE\Class\Folder\shell下新建一个键，比如“CMD Prompt”（见文章后面12年12月1日的更新），将其中的default值改成任意你想显示的右键菜单名称。 在上面创建的键下面在创建一个键，名称必须为“command”，将其中的default值改成“cmd.exe /k pushd %1”。 修改立即生效，现在点右键就能看到新的菜单项了。 &#160; 更新（2012-12-01）：如果将shell下面的键名字改成“runas”，那打开的CMD窗口将是管理员身份的。懒得手动操作的朋友可以直接导入这个注册表文件（ADMIN_CMD.ZIP）。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15561">Windows系统下给文件夹增加自定义右键菜单</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>对于开发人员来说，经常需要使用命令行并且切换到某个指定的目录中去。可以通过给文件夹增加一个右键菜单（比如Open in CMD）来完成。</p>
<p>只要在注册表中增加下面的键值就能完成：</p>
<p>在HKLM\SOFTWARE\Class\Folder\shell下新建一个键，比如“CMD Prompt”（见文章后面12年12月1日的更新），将其中的default值改成任意你想显示的右键菜单名称。</p>
<p>在上面创建的键下面在创建一个键，名称必须为“command”，将其中的default值改成“cmd.exe /k pushd %1”。</p>
<p><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu.png"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15562" title="注册表中给文件夹增加右键菜单" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu-300x147.png" alt="注册表中给文件夹增加右键菜单" width="300" height="147" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu-300x147.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu.png 644w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>修改立即生效，现在点右键就能看到新的菜单项了。</p>
<p><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu2.png"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15563" title="自定义的右键菜单" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu2-300x134.png" alt="自定义的右键菜单" width="300" height="134" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu2-300x134.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/ContextMenu2.png 306w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>&nbsp;</p>
<p><strong>更新（2012-12-01）</strong>：如果将shell下面的键名字改成“runas”，那打开的CMD窗口将是管理员身份的。懒得手动操作的朋友可以直接导入这个注册表文件（<a href="https://www.xiaomingtu.com/wp-content/uploads/2012/12/ADMIN_CMD.zip">ADMIN_CMD.ZIP</a>）。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15561">Windows系统下给文件夹增加自定义右键菜单</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15561/feed</wfw:commentRss>
			<slash:comments>107</slash:comments>
		
		
			</item>
		<item>
		<title>修改Visual Studio 2010和Windows注册用户信息</title>
		<link>https://www.xiaomingtu.com/archives/15550?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e4%25bf%25ae%25e6%2594%25b9visual-studio-2010%25e5%2592%258cwindows%25e6%25b3%25a8%25e5%2586%258c%25e7%2594%25a8%25e6%2588%25b7%25e4%25bf%25a1%25e6%2581%25af</link>
					<comments>https://www.xiaomingtu.com/archives/15550#respond</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Fri, 31 Aug 2012 11:17:54 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[桌面应用]]></category>
		<category><![CDATA[VisualStudio2010]]></category>
		<category><![CDATA[VS]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows7]]></category>
		<category><![CDATA[windows8]]></category>
		<category><![CDATA[用户名]]></category>
		<category><![CDATA[组织]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15550</guid>

					<description><![CDATA[<p>在VS2010的闪屏以及关于对话框中有用户及组织的信息： 可以通过修改注册表来修改上面的信息： 32位系统： 用户名：HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\Registration中的UserName 组织信息：HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion中的RegisteredOrganization 修改UserName之后并不会马上生效，需要使用执行“devenv.exe /setup”让IDE重置之后才会生效。 &#160; Windows的用户名信息：HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion中的RegisteredOwner 组织信息与上面VS的组织信息是一样的。 通过修改Windows的这两个信息，以后安装软件就会默认使用这个新的名称。 &#160; 64位系统： 用户名：HKLM\SOFTWARE\WoW6432Node\Microsoft\VisualStudio\10.0\Registration中的UserName 组织信息：HKLM\SOFTWARE\WoW6432Node\Microsoft\Windows NT\CurrentVersion中的RegisteredOrganization Windows的用户名信息：HKLM\SOFTWARE\WoW6432Node\Microsoft\Windows NT\CurrentVersion中的RegisteredOwner</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15550">修改Visual Studio 2010和Windows注册用户信息</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>在VS2010的闪屏以及关于对话框中有用户及组织的信息：</p>
<p><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/Splash.png"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15552" title="VS2010闪屏画面" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/Splash-300x212.png" alt="VS2010闪屏画面" width="300" height="212" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/Splash-300x212.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/Splash.png 540w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/About.png"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15551" title="关于对话框" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/About-300x224.png" alt="VS2010关于对话框" width="300" height="224" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/About-300x224.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/About.png 790w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>可以通过修改注册表来修改上面的信息：<span id="more-15550"></span></p>
<p><strong>32位系统</strong>：</p>
<p>用户名：<strong>HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\Registration</strong>中的<strong>UserName</strong></p>
<p>组织信息：<strong>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion</strong>中的<strong>RegisteredOrganization</strong></p>
<p>修改UserName之后并不会马上生效，需要使用执行“<strong><span style="color: #ff0000;">devenv.exe /setup</span></strong>”让IDE重置之后才会生效。</p>
<p>&nbsp;</p>
<p>Windows的用户名信息：<strong>HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion</strong>中的<strong>RegisteredOwner</strong></p>
<p>组织信息与上面VS的组织信息是一样的。</p>
<p>通过修改Windows的这两个信息，以后安装软件就会默认使用这个新的名称。</p>
<p>&nbsp;</p>
<p><strong>64位系统</strong>：</p>
<p>用户名：<strong>HKLM\SOFTWARE\WoW6432Node\Microsoft\VisualStudio\10.0\Registration</strong>中的<strong>UserName</strong></p>
<p>组织信息：<strong>HKLM\SOFTWARE\<strong>WoW6432Node\</strong>Microsoft\Windows NT\CurrentVersion</strong>中的<strong>RegisteredOrganization</strong></p>
<p>Windows的用户名信息：<strong>HKLM\SOFTWARE\<strong>WoW6432Node\</strong>Microsoft\Windows NT\CurrentVersion</strong>中的<strong>RegisteredOwner</strong></p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15550">修改Visual Studio 2010和Windows注册用户信息</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15550/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>.NET中的垃圾回收机制</title>
		<link>https://www.xiaomingtu.com/archives/15531?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=net%25e4%25b8%25ad%25e7%259a%2584%25e5%259e%2583%25e5%259c%25be%25e5%259b%259e%25e6%2594%25b6%25e6%259c%25ba%25e5%2588%25b6</link>
					<comments>https://www.xiaomingtu.com/archives/15531#comments</comments>
		
		<dc:creator><![CDATA[Xiaoming]]></dc:creator>
		<pubDate>Wed, 15 Aug 2012 21:21:24 +0000</pubDate>
				<category><![CDATA[专业技术]]></category>
		<category><![CDATA[开发语言]]></category>
		<category><![CDATA[有图有真相]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[GC]]></category>
		<category><![CDATA[内存]]></category>
		<category><![CDATA[垃圾回收]]></category>
		<guid isPermaLink="false">http://www.xiaomingtu.com/?p=15531</guid>

					<description><![CDATA[<p>通过一个小程序介绍了.NET中的内存管理机制。</p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15531">.NET中的垃圾回收机制</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>在.NET中，应用程序的内存分成两个部分，一部分为托管内存，由.NET运行时（CLR）进行管理；另外一部分为非托管内存（通过Win32 API或者Marshal.AllocateXXX方法分配），需要程序员自己进行管理。托管内存都在堆（Heap）中进行分配，在这个堆中，.NET通过不同的“代”（Generation）来组织对象。托管堆共分成三代：<span id="more-15531"></span></p>
<ul>
<li>第0代（Generation 0）：这一代是最年轻的，其中包含一些短生存期的对象，比如方法中的局部变量等。这一代的对象会被回收的比较频繁，在新建对象的时候，一般会创建在这一代中。</li>
<li>第1代（Generation 1）：这一代中的对象也是短生存期的，但只是作为一个过渡。一些较大的对象，在创建的时候也会在这一代。</li>
<li>第2代（Generation 2）：这一代中的对象都是长生存期的，比如静态类、静态成员等。他们被回收的概率会很低，所以在编写程序的时候应该尽量避免使用静态成员。</li>
</ul>
<p>在每一代中的执行（通过显式调用GC.Collect方法）一次内存回收时，如果有对象无法被回收，它们将被移到下一代中。比如第1代中定义了一个对象，它在一次回收操作中无法被回收，那它就会被移到第1代中去。这样的好处就是移动之后的对象下次不会再被频繁的尝试去回收。因为越是后代中的对象，被回收的频率就越低。</p>
<p>下面通过一个非常简单的程序来演示内存回收，它主要的功能是通过一个循环不断地创建一个数组，我们主要研究这些数组所占用的内存在何时会被回收。代码中的Sleep语句主要是为了让结果显示的明显一些，否则因为时间间隔太小，而看不清楚内存的变化。接下去的测试都是基于下面的代码：</p><pre class="urvanov-syntax-highlighter-plain-tag">using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 10;
            float[] x = null;

            for (int i = 0; i &lt; N; i++)
            {
                Console.WriteLine(i.ToString());

                x = new float[1000000];
                //Thread.Sleep(1000);
                //GC.Collect();
            }

            x = null;
        }
    }
}</pre><p>第一次尝试，数组大小为1000，未开启Collect：</p>
<p style="text-align: center;"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/1.png" target="_blank"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15536" title="第一次尝试结果" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/1-300x175.png" alt="第一次尝试结果" width="300" height="175" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/1-300x175.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/1.png 1538w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>上图纵坐标为程序占用的内存数（字节）；横坐标是执行时间（秒）（下同）。可以看到内存一直在增加，并没有降低过。</p>
<p>第二次尝试，数组大小为1000，开启Collect：</p>
<p style="text-align: center;"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/2.png" target="_blank"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15537" title="第二次尝试" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/2-300x175.png" alt="第二次尝试" width="300" height="175" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/2-300x175.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/2.png 1538w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>我们可以看到，每隔一秒钟（就是我们Sleep的时间），内存就会下降一块。</p>
<p>第三次尝试，数组大小为1000000，未开启Collect：</p>
<p style="text-align: center;"><a href="https://www.xiaomingtu.com/wp-content/uploads/2012/08/3.png" target="_blank"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-15538" title="第三次尝试" src="https://www.xiaomingtu.com/wp-content/uploads/2012/08/3-300x175.png" alt="第三次尝试" width="300" height="175" srcset="https://www.xiaomingtu.com/wp-content/uploads/2012/08/3-300x175.png 300w, https://www.xiaomingtu.com/wp-content/uploads/2012/08/3.png 1538w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>结果与第二次尝试类似，因为每次创建的数组大小非常大，已经达到垃圾回收器内置的阈值，所以会自动执行回收。</p>
<p>垃圾回收器的工作机制比较复杂，已经不在本文的讨论范围内了，有兴趣的同学可以参考MSDN中的相关文章。推荐下面一片文章，介绍了GC的基本知识以及一些性能提升点：</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms973837.aspx">http://msdn.microsoft.com/en-us/library/ms973837.aspx</a></p>
<p>The post <a href="https://www.xiaomingtu.com/archives/15531">.NET中的垃圾回收机制</a> appeared first on <a href="https://www.xiaomingtu.com">Xiaoming Tu - Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.xiaomingtu.com/archives/15531/feed</wfw:commentRss>
			<slash:comments>382</slash:comments>
		
		
			</item>
	</channel>
</rss>
