我开发了一个概念验证应用程序,用于查询WCF是否支持多线程.
现在,我所做的就是创建一个标有的服务合同
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
ConcurrencyMode = ConcurrencyMode.Multiple,
UseSynchronizationContext = true)]
Run Code Online (Sandbox Code Playgroud)
有两个操作来获取固定文本.第一种方法执行a Thread.Sleep8秒钟以使响应延迟,另一种方法直接返回数据.
我遇到的问题是当我运行两个客户端应用程序实例并从第一个客户端请求延迟方法并从第二个客户端请求另一个方法时,我得到了一个顺序响应.
当服务忙于另一个请求时,如何从服务获得响应?
namespace WCFSyncService
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)],
ConcurrencyMode = ConcurrencyMode.Multiple,
UseSynchronizationContext = true)]
public class ServiceImplementation : IService
{
public ServiceImplementation()
{
}
#region IService Members
public string GetDelayedResponse()
{
System.Threading.Thread.Sleep(8000);
return "Slow";
}
public string GetDirectResponse()
{
return "Fast";
}
#endregion
}
}
Run Code Online (Sandbox Code Playgroud)
我需要调用方法GetDelayedResponse,GetDirectResponse同时在8秒结束前获得"快速"文本.
托管应用程序代码
namespace ServiceHostApplication
{
public partial class frmMain : Form
{
private WCFSessionServer.IService oService;
public frmMain() …Run Code Online (Sandbox Code Playgroud) 我有一个在XAML文件中定义的矢量图像
Image.xaml
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="appbar_power" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="38" Height="41.1667" Canvas.Left="19" Canvas.Top="17.4167" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M 36.4167,36.4167L 36.4167,17.4167L 41.1667,17.4167L 41.1667,36.4167L 36.4167,36.4167 Z M 57,39.5833C 57,50.0767 48.4934,58.5833 38,58.5833C 27.5066,58.5833 19,50.0767 19,39.5833C 19,30.7301 25.0552,23.2911 33.25,21.1819L 33.25,27.8374C 28.6079,29.7165 25.3333,34.2675 25.3333,39.5833C 25.3333,46.5789 31.0044,52.25 38,52.25C 44.9956,52.25 50.6667,46.5789 50.6667,39.5833C 50.6667,34.8949 48.1194,30.8014 44.3333,28.6113L 44.3333,21.6645C 51.7129,24.2728 57,31.3106 57,39.5833 Z "/>
</Canvas>
Run Code Online (Sandbox Code Playgroud)
如果我修改此图像的XAML代码(例如Path的Fill属性),则会立即在Visual Studio 2015的"设计"窗口中显示更改.
现在我想创建一个引用此图像的ResourceDictionary.我将xaml代码直接包含在ResourceDictionary中,但在这种情况下我失去了预览的能力(Visual Studio中没有设计窗口,我得到"MyResourceDictionary.xaml无法在设计视图中编辑").
MyResourceDictionary.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Project.XamlResources">
<Canvas x:Key="appbar_power" x:Name="appbar_power" Width="76" Height="76" Clip="F1 M …Run Code Online (Sandbox Code Playgroud)