Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Last active December 11, 2015 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpolvora/4576913 to your computer and use it in GitHub Desktop.
Save jpolvora/4576913 to your computer and use it in GitHub Desktop.
/* REFERENCIAR o assembly System.ServiceModel.dll */
using System.ServiceModel;
using System.ServiceModel.DomainServices.Client;
partial class MyDomainContext {
partial void OnCreated() {
var timeSpan = TimeSpan.FromSeconds(30); /* 30 segundos de timeout */
DomainContextExtensions.ChangeWcfSendTimeout(this, timeSpan);
}
/* colocar este método numa classe static p/ extensões, por exemplo DomainContextExtensions.cs*/
public static void ChangeWcfSendTimeout(DomainContext context, TimeSpan sendTimeout) {
var channelFactoryProperty = context.DomainClient.GetType().GetProperty("ChannelFactory");
if (channelFactoryProperty == null) {
throw new InvalidOperationException("There is no 'ChannelFactory' property on the DomainClient.");
}
var factory = (ChannelFactory)channelFactoryProperty.GetValue(context.DomainClient, null);
factory.Endpoint.Binding.SendTimeout = sendTimeout;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment