Loading blog entries.. loading

A good lesson and experience

Thursday, September 3, 2009 10:46 PM
Written by Wayne Ye
Font Size: S  M  L 

I was extremely busy during the last two weeks, since our project was at bug fixing phase, my team and I worked really hard on dealing with the bugs; We fixed two to three bugs everyday by average, I am very satisfied with the efficiency myself.

During this process, I encountered several very interesting issues.

  1. There was a crash bug with P1 priority, we all cannot reproduced it until one guy from US team provided a remote server that our product always crashed, after I logged onto that server and 20 minutes investigating, I was really surprised, the reason is one line of code written by myself, it is:

    DateTime.Parse(String.Format("{0}/{1}/{2} 00:00:00 AM", DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year))

    Does this line of code has any problem, I definitely don’t think so before, but now, I understand, it only works under English format, once non-English format, under some format such as Chinese, the AM makes non sense; and… Under some formats (such as French), the code will throw FormatException and leads program crash…

  2. Another issue is a WPF related multi-threading issue, there is a module in our product used thread pool to invoke WMI APIs to get the drives' information, once done the thread updates a Boolean flag indicate it is ready to bind data onto UI, once the flag changes, it will notify WPF main thread (two WPF pages subscribed this), but the problem is, the one of them directly starts binding data, since it will be done in the thread created by thread pool, WPF does NOT allow this, an InvalidOperationException will be thrown and leads product crash.
  3. The solution is straight forward: Let main thread updates the Boolean flag, so that both two subscribing page can simply just wait for it and do the binding.

Interesting, hum:)

 

Permalink: http://wayneye.com/Blog/A-Good-Lesson-On-DateTime-Localization 2771 Views  0 Comments
Tag: Category:Programming»Windows Development»Misc

 

 


↓Comments↓

No comments so far, be the first one!

Your view point or opinion?
Nickname *
 
Gravatar *
Required (not shown), used only for displaying Gravatar and receiving future notification when new comment(s) posted on this blog.
 
Website/Blog
 
Content *
Current length:     Maximum allowed: charactors