Skip to content

Commit

Permalink
allow to force refreshing the hard-drive
Browse files Browse the repository at this point in the history
  • Loading branch information
NobodysNightmare committed Jul 6, 2014
1 parent bc3c769 commit e2b9dfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions DriveKeepAlive/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Window x:Class="DriveKeepAlive.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Drive Keep-alive" Height="115.672" Width="525" Closed="Window_Closed_1" ResizeMode="CanMinimize">
Title="Drive Keep-alive" Height="152.672" Width="525" Closed="Window_Closed_1" ResizeMode="CanMinimize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="41*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="46*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="WriteCountLabel" Grid.Row="0" Margin="10,10,332,10" ><Run Text="write cycles"/></TextBlock>
<TextBlock x:Name="IdleCountLabel" Text="idle cycles" Grid.Row="1" Margin="10" />
<TextBlock x:Name="PathLabel" Text="Directory" HorizontalAlignment="Right" Margin="0,10,9,10" />

<CheckBox x:Name="forceRefreshCheckBox" Grid.Row="2" Content="Force Refreshing" Checked="forceRefreshCheckBox_Checked"/>
</Grid>
</Window>
8 changes: 7 additions & 1 deletion DriveKeepAlive/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace DriveKeepAlive
/// </summary>
public partial class MainWindow : Window
{
private bool ForceRefresh;
private Stream FileStream;
private AppSettings Config = AppSettings.Default;

Expand All @@ -44,7 +45,7 @@ private void KeepAliveCycle()
long idleCount = 0;
while (true)
{
if (IsUserActive())
if (IsUserActive() || ForceRefresh)
{
WriteToKeepAliveFile();
UpdateStatusText(++writeCount, idleCount);
Expand Down Expand Up @@ -96,5 +97,10 @@ private void Window_Closed_1(object sender, EventArgs e)
{
FileStream.Close();
}

private void forceRefreshCheckBox_Checked(object sender, RoutedEventArgs e)
{
ForceRefresh = forceRefreshCheckBox.IsChecked.Value;
}
}
}

0 comments on commit e2b9dfc

Please sign in to comment.