小编Fra*_*nkE的帖子

WCF回调接口 - 谁关闭了频道

关闭回拨/双工通信通道时遇到问题/疑问.以下是我的原型WCF接口:

[ServiceContract(CallbackContract = typeof(IMyInterfaceCallback))]
public interface IMyInterface
{
    [OperationContract]
    void StartWork();
}

public interface IMyInterfaceCallback
{
    [OperationContract(IsOneWay = true)]
    void WorkFeedback();
}
Run Code Online (Sandbox Code Playgroud)

在客户端,我通过以下方式创建我的WCF接口:

DuplexChannelFactory<IMyInterface> dcf = new DuplexChannelFactory<IMyInterface>(implOfIMyInterfaceCallback, customBinding, ea);
IMyInterface myInterface = dcf.CreateChannel();
Run Code Online (Sandbox Code Playgroud)

然后我在服务器端使用

OperationContext.Current.GetCallbackChannel<IMyInterfaceCallback>();
Run Code Online (Sandbox Code Playgroud)

检索回调指针,然后可以使用该指针与客户端进行通信.

我现在的问题是:

  1. 谁应该关闭沟通渠道?客户端或服务器
  2. 需要关闭哪些通信对象?原始接口(IMyInterface)或回调接口(IMyInterfaceCallback)或两者.

我试图关闭服务器端的回调接口,当时服务器知道它不会再进行回调.然而,在回调接口上使用ICommunicationObject :: Close会导致一分钟的阻塞操作.

在我看来,在客户端关闭并不是正确的方法,因为客户端不知道是否有更多的回调需要预期.

谢谢你的帮助.坦率

PS:这似乎是一个非常基本的问题,但到目前为止,我通过谷歌搜索或在stackoverflow中找不到有用的信息......

wcf

7
推荐指数
2
解决办法
5158
查看次数

DataGridCell Validation.ErrorTemplate被忽略

我正在尝试设置DataGridCells的Validation.ErrorTemplate,这是xaml代码:

<Style x:Key="{x:Type DataGridCell}"  x:Uid="dataGridCellErrorTemplate" TargetType="{x:Type DataGridCell}">
    <Setter Property="Validation.ErrorTemplate">
        <Setter.Value>
            <ControlTemplate >
                <Border BorderBrush="Green" BorderThickness="2" ToolTip="Heidenei"></Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <!-- following line only for demonstration that the setter is working ... -->
    <Setter Property="Background" Value="Aquamarine"></Setter>              
</Style>
Run Code Online (Sandbox Code Playgroud)

当datagridcells的背景成功地变为绿色(与任何验证结果无关)时,使用的Validation.ErrorTemplate仍然是默认值,即红色边框。

我知道在stackoverflow中也有类似的问题,例如,设置 DataGridCell错误模板的样式, 但它们并不能真正解决我的问题。

任何帮助表示赞赏

坦率

validation wpf datagrid idataerrorinfo

6
推荐指数
1
解决办法
1971
查看次数

DateTimePicker控件不显示AM/PM

我使用自定义格式的DateTimePicker控件出现问题,该格式包含两个字母的AM/PM缩写.

使用"en-US"CultureInfo DateTimeFormat.ShortTimePattern得到"h:mm tt".

但是使用以下代码在DateTimePicker中将其设置为自定义格式:

Dim curCul As CultureInfo = New CultureInfo("en-US")
dtpTime.Format = DateTimePickerFormat.Custom
dtpTime.CustomFormat = curCul.DateTimeFormat.ShortTimePattern
Run Code Online (Sandbox Code Playgroud)

结果只显示小时和分钟.然而,我还需要AM/PM部分.

例子:

上午11:04显示为11:04

下午2:00显示为2:00

补充说明:我注意到DateTimePicker会跟踪正确的时间.如果我增加时间(我对此DateTimePicker控件使用ShowUpDown = true)并将小时增加12并将更改保存到数据库中,则AM/PM已更改.因此,关于显示AM/PM部件的问题似乎"仅".

谢谢你的帮助.坦率

vb.net datetimepicker datetime-format winforms

5
推荐指数
1
解决办法
1万
查看次数