8000 added an global exception-handling · dadul96/TCP_Server_Client_Tester@36c6ccb · GitHub
[go: up one dir, main page]

Skip to content

Commit 36c6ccb

Browse files
committed
added an global exception-handling
changed some GUI elements changed the server and client loops other minor changes
1 parent 3093fcc commit 36c6ccb

File tree

4 files changed

+249
-122
lines changed

4 files changed

+249
-122
lines changed

TCP_Server_Client_Tester/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:TCP_Server_Client_Tester"
5+
DispatcherUnhandledException="Application_DispatcherUnhandledException"
56
StartupUri="MainWindow.xaml">
67
<Application.Resources>
78

TCP_Server_Client_Tester/App.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ namespace TCP_Server_Client_Tester
1313
/// </summary>
1414
public partial class App : Application
1515
{
16+
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
17+
{
18+
MessageBox.Show("An unhandled exception just occurred: " + e.Exception.Message, "Global backup exception catcher", MessageBoxButton.OK, MessageBoxImage.Warning);
19+
e.Handled = true;
20+
}
1621
}
1722
}

TCP_Server_Client_Tester/MainWindow.xaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<RowDefinition Height="*" />
4141
</Grid.RowDefinitions>
4242
<TextBox x:Name="serverSendTextbox1" Grid.Column="0" Grid.Row="0" Margin="5,5,5,5"/>
43-
<Button Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,0" Height="20" VerticalAlignment="Top" Click="Button_Click"/>
43+
<Button x:Name="serverSendButton1" Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,0" Height="20" VerticalAlignment="Top" Click="serverSendButton1_Click" IsEnabled="false"/>
4444
</Grid>
4545

4646
<Grid Grid.Column="0" Grid.Row="2">
@@ -52,7 +52,7 @@
5252
<RowDefinition Height="*" />
5353
</Grid.RowDefinitions>
5454
<TextBox x:Name="serverSendTextbox2" Grid.Column="0" Grid.Row="0" Margin="5,5,5,5"/>
55-
<Button Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5" Click="Button_Click_1"/>
55+
<Button x:Name="serverSendButton2" Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5" Click="serverSendButton2_Click" IsEnabled="false"/>
5656
</Grid>
5757

5858
</Grid>
@@ -80,9 +80,7 @@
8080

8181
<Label Content="Port:" Grid.Column="0" Grid.Row="0" VerticalAlignment="Bottom"/>
8282
<TextBox x:Name="serverPort" Text="233" Grid.Column="0" Grid.Row="1" Margin="5,0,5,10"/>
83-
<Label Content="IP (read only):" Grid.Column="0" Grid.Row="2" VerticalAlignment="Bottom"/>
84-
<TextBox x:Name="serverIP" Text="0.0.0.0" Grid.Column="0" Grid.Row="3" Margin="5,0,5,10" IsEnabled="false"/>
85-
<Button x:Name="serverStartButton" Content="Listen" Grid.Column="0" Grid.Row="4" Margin="5,5,5,5" Background="LightGreen" FontWeight="Bold" Click="serverStartButton_Click"/>
83+
<Button x:Name="serverStartButton" Content="Listen" Grid.Column="0" Grid.Row="2" Margin="5,5,5,5" Background="LightGreen" FontWeight="Bold" Click="serverStartButton_Click"/>
8684
</Grid>
8785
</Grid>
8886
</TabItem>
@@ -119,7 +117,7 @@
119117
<RowDefinition Height="*" />
120118
</Grid.RowDefinitions>
121119
<TextBox x:Name="clientSendTextbox1" Grid.Column="0" Grid.Row="0" Margin="5,5,5,5"/>
122-
<Button Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5" Click="Button_Click_2"/>
120+
<Button x:Name="clientSendButton1" Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5" Click="clientSendButton1_Click" IsEnabled="false"/>
123121
</Grid>
124122

125123
<Grid Grid.Column="0" Grid.Row="2">
@@ -131,7 +129,7 @@
131129
<RowDefinition Height="*" />
132130
</Grid.RowDefinitions>
133131
<TextBox x:Name="clientSendTextbox2" Grid.Column="0" Grid.Row="0" Margin="5,5,5,5"/>
134-
<Button Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5" Click="Button_Click_3"/>
132+
<Button x:Name="clientSendButton2" Content="Send" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5" Click="clientSendButton2_Click" IsEnabled="false"/>
135133
</Grid>
136134

137135
</Grid>
@@ -160,7 +158,7 @@
160158
<Label Content="Port:" Grid.Column="0" Grid.Row="0" VerticalAlignment="Bottom"/>
161159
<TextBox x:Name="clientPort" Text="233" Grid.Column="0" Grid.Row="1" Margin="5,0,5,10"/>
162160
<Label Content="IP:" Grid.Column="0" Grid.Row="2" VerticalAlignment="Bottom"/>
163-
<TextBox x:Name="clientIP" Text="0.0.0.0" Grid.Column="0" Grid.Row="3" Margin="5,0,5,10"/>
161+
<TextBox x:Name="clientIP" Text="192.168.144.1" Grid.Column="0" Grid.Row="3" Margin="5,0,5,10"/>
164162
<Button x:Name="clientStartButton" Content="Connect" Grid.Column="0" Grid.Row="4" Margin="5,5,5,5" Background="LightGreen" FontWeight="Bold" Click="clientStartButton_Click"/>
165163
</Grid>
166164
</Grid>

0 commit comments

Comments
 (0)
0