The C# memory model makes and shows the code patterns that motivate the guarantees; the second part will detail how the guarantees are achieved on different hardware architectures in the Microsoft .NET Framework 4.5.
One source of complexity in multithreaded programming is that the compiler and the hardware can subtly transform a program’s memory operations in ways that don’t affect the single-threaded behavior, but might affect the multithreaded behavior.
- Calculations and comparisons of DateTime instances are only meaningful when the instances being compared or used are representations of points in time from the same time-zone perspective.
- A developer is responsible for keeping track of time-zone information associated with a DateTime value via some external mechanism. Typically this is accomplished by defining another field or variable that you use to record time-zone information when you store a DateTime value type. This approach (storing the time-zone sense alongside the DateTime value) is the most accurate and allows different developers at different points in a program’s lifecycle to always have a clear understanding of the meaning of a DateTime value. Another common approach is to make it a “rule” in your design that all time values are stored in a specific time-zone context. This approach does not require additional storage to save a user’s view of the time-zone context, but introduces the risk that a time value will be misinterpreted or stored incorrectly down the road by a developer that isn’t aware of the rule.
I had to host some files on Google Drive and they needed to be updated on regular basis. Going through the GUI is a tedious task if repeated often, so I ended up coding my own upload code.
The upload login is just using the Google SDK, but the tricky part is the authentication with the Google Services, which is OAuth 2.0 ticket base and needs interaction at least for the first run of the program.
Here is the Google Drive encapsulated logic. It exposes methods for listing the drive contents, downloading and uploading:
And here is the application logic. It’s just a command line utility that accepts the client Id and secret as first parameter and the file to be uploaded as third:
And the rest is the most tricky part. The authentication:
WPF provides an innovative feature called attached properties, which can be used to add behavior to existing controls. These new properties are not defined on the control being extended, but rather they are defined on a separate object (generally a
DependencyObject). Thus, we end up with a source object that defines the attached properties and a target object on which you attach these properties. The target is the object being extended with new functionality contained in the source. When the attached property is set on the target object, a property change event is fired on the source. The event handler is passed information about the target and the new and old values of the property.
By hooking up property changed handlers, we can add additional behavior by calling methods on the target, changing properties, and listening to events. We look at more detailed examples of using attached properties in Chapter 6, “The Power of Attached Properties.” Keep in mind that…
View original post 392 more words
This article will show you the way to change the cell in WPF Datagrid.
I have been reading people asking how to change the cell in WPF Datagrid. A lot of article with a lot of theory somehow the code won’t work.
I give you only 2 pieces of code here.
The first one, MainWindow.xaml. Replace your xaml code with the code below.
Title=”MainWindow” Height=”350″ Width=”525″>
<DataGrid Name=”dataGrid1″ HorizontalAlignment=”Left” Height=”160″ Margin=”26,23,0,0″ VerticalAlignment=”Top” Width=”419″ AutoGenerateColumns=”True” />
<Button Content=”Refresh” HorizontalAlignment=”Left” Margin=”26,211,0,0″ VerticalAlignment=”Top” Width=”75″ Click=”Button_Click”/>
<Button Content=”Modify” HorizontalAlignment=”Left” Margin=”123,211,0,0″ VerticalAlignment=”Top” Width=”75″ Click=”Button_Click_1″/>
<Label Name=”label1″ Content=”Label” HorizontalAlignment=”Left” Margin=”26,255,0,0″ VerticalAlignment=”Top” Width
View original post 447 more words
Caching is one of the most difficult tasks to get right!