summaryrefslogtreecommitdiff
path: root/cs/demo/Ice/wpf/HelloWindow.xaml.cs
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2014-07-11 08:59:44 -0230
committerMatthew Newhook <matthew@zeroc.com>2014-07-11 08:59:44 -0230
commitd00b3fe3835eda362f259bef48775b09846d1546 (patch)
tree18cc9897797574e662b23d4119ab04f11f9202be /cs/demo/Ice/wpf/HelloWindow.xaml.cs
parentFixed ICE-5379, Object Adapter should reject null servant, in C++, Java, C# a... (diff)
downloadice-d00b3fe3835eda362f259bef48775b09846d1546.tar.bz2
ice-d00b3fe3835eda362f259bef48775b09846d1546.tar.xz
ice-d00b3fe3835eda362f259bef48775b09846d1546.zip
ICE-5513 - Fix the C# demos to use lambda expressions
- Simplified and refactored some C# tests to use lambdas. - Changed the operations and ami test to test both lambda and delegate based callbacks. - In cs/test/Ice/timeout changed TimeoutException to InvocationTimeoutException for the invocation timeout test.
Diffstat (limited to 'cs/demo/Ice/wpf/HelloWindow.xaml.cs')
-rw-r--r--cs/demo/Ice/wpf/HelloWindow.xaml.cs100
1 files changed, 39 insertions, 61 deletions
diff --git a/cs/demo/Ice/wpf/HelloWindow.xaml.cs b/cs/demo/Ice/wpf/HelloWindow.xaml.cs
index 19fe06745e3..faefe0520b7 100644
--- a/cs/demo/Ice/wpf/HelloWindow.xaml.cs
+++ b/cs/demo/Ice/wpf/HelloWindow.xaml.cs
@@ -52,7 +52,7 @@ namespace Ice.wpf.client
Ice.InitializationData initData = new Ice.InitializationData();
initData.properties = Ice.Util.createProperties();
initData.properties.load("config.client");
- initData.dispatcher = delegate(System.Action action, Ice.Connection connection)
+ initData.dispatcher = (System.Action action, Ice.Connection connection) =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
};
@@ -120,56 +120,6 @@ namespace Ice.wpf.client
return prx;
}
- class SayHelloCB
- {
- public SayHelloCB(HelloWindow window)
- {
- _window = window;
- }
-
- public void response()
- {
- lock(this)
- {
- Debug.Assert(!_response);
- _response = true;
- _window.status.Content = "Ready";
- }
- }
-
- public void exception(Exception ex)
- {
- lock(this)
- {
- Debug.Assert(!_response);
- _response = true;
- _window.handleException(ex);
- }
- }
-
- public void sent(bool sentSynchronously)
- {
- lock(this)
- {
- if(_response)
- {
- return;
- }
- if(_window.deliveryMode.Text.Equals(TWOWAY) || _window.deliveryMode.Text.Equals(TWOWAY_SECURE))
- {
- _window.status.Content = "Waiting for response";
- }
- else
- {
- _window.status.Content = "Ready";
- }
- }
- }
-
- private bool _response = false;
- private HelloWindow _window;
- }
-
private void sayHello_Click(object sender, RoutedEventArgs e)
{
Demo.HelloPrx hello = createProxy();
@@ -184,8 +134,35 @@ namespace Ice.wpf.client
if(!deliveryModeIsBatch())
{
status.Content = "Sending request";
- SayHelloCB cb = new SayHelloCB(this);
- hello.begin_sayHello(delay).whenCompleted(cb.response, cb.exception).whenSent(cb.sent);
+ bool haveResponse = false;
+ hello.begin_sayHello(delay).whenCompleted(
+ () =>
+ {
+ Debug.Assert(!haveResponse);
+ haveResponse = true;
+ status.Content = "Ready";
+ },
+ (Ice.Exception ex) =>
+ {
+ Debug.Assert(!haveResponse);
+ haveResponse = true;
+ handleException(ex);
+ }).whenSent(
+ (bool sentSynchronously) =>
+ {
+ if (haveResponse)
+ {
+ return;
+ }
+ if (deliveryMode.Text.Equals(TWOWAY) || deliveryMode.Text.Equals(TWOWAY_SECURE))
+ {
+ status.Content = "Waiting for response";
+ }
+ else
+ {
+ status.Content = "Ready";
+ }
+ });
}
else
{
@@ -221,14 +198,15 @@ namespace Ice.wpf.client
{
AsyncResult<Demo.Callback_Hello_shutdown> result = hello.begin_shutdown();
status.Content = "Sending request";
- result.whenCompleted(delegate()
- {
- status.Content = "Ready";
- },
- delegate(Exception ex)
- {
- handleException(ex);
- });
+ result.whenCompleted(
+ () =>
+ {
+ status.Content = "Ready";
+ },
+ (Exception ex) =>
+ {
+ handleException(ex);
+ });
}
else
{