本文整理汇总了C#中ServiceClient.Abort方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.Abort方法的具体用法?C# ServiceClient.Abort怎么用?C# ServiceClient.Abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.Abort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorkflowExtensionsBehaviorAddsExtension
public void WorkflowExtensionsBehaviorAddsExtension()
{
WorkflowServiceTestHost host = null;
// TODO: Test with multiple extensions
// TODO: Test with bad config file entries
var serviceEndpoint1 = ServiceTest.GetUniqueEndpointAddress();
using (host = WorkflowServiceTestHost.Open("ServiceExtensionTest.xamlx", serviceEndpoint1))
{
try
{
var proxy = new ServiceClient(ServiceTest.Pipe, serviceEndpoint1);
try
{
proxy.GetData(1);
proxy.Close();
}
catch (Exception)
{
proxy.Abort();
throw;
}
}
finally
{
if (host != null)
{
host.Tracking.Trace();
}
}
}
}
示例2: syncOperation
public static void syncOperation()
{
//client.ServiceReference1.ServiceClient client = new client.ServiceReference1.ServiceClient(new BasicHttpBinding(),new EndpointAddress(""));
client.ServiceReference1.ServiceClient client = new ServiceClient("NetTcpBinding_IService");
try
{
Data s1 = new Data() { name="saeid1"};
Data s2 = new Data() { name = "saeid2" };
client.addData(s1);
client.addData(s2);
Data[] result = client.getList();
Console.WriteLine("number of entries: " + result.Length);
client.Close();
}
catch (FaultException fe)
{
Console.WriteLine(fe.GetType());
client.Abort();
}
catch (CommunicationException ce)
{
Console.WriteLine(ce.GetType());
Console.WriteLine(ce.Message);
client.Abort();
}
catch (TimeoutException te)
{
Console.WriteLine(te.GetType());
client.Abort();
}
}
示例3: UploadFile
public static void UploadFile(string localFileName,FileTypeEnum fileType)
{
eAdDataAccess.ServiceClient service = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
try
{
using (Stream fileStream = new FileStream(localFileName, FileMode.Open, FileAccess.Read))
{
// var request = new FileUploadMessage();
string remoteFileName = null;
if (fileType == FileTypeEnum.Generic)
{
// WE ARE USING THE SERVICE AS A "FTP ON WCF"
// GIVE THE REMOTE FILE THE SAME NAME AS THE LOCAL ONE
remoteFileName = Path.GetFileName(localFileName);
}
var fileMetadata = new FileMetaData { LocalFilename = localFileName, RemoteFilename = remoteFileName,FileType = fileType};
// request.MetaData = fileMetadata;
// request.FileByteStream = fileStream;
//service.UploadFile(fileMetadata,fileStream);
service.Close();
}
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
service.Abort();
}
catch (CommunicationException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
service.Abort();
}
}
示例4: ButtonSubmit_Click
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
var proxy = new ServiceClient();
try
{
var sampleResponse = proxy.GetData(TextBoxKey.Text);
LabelValue.Text = sampleResponse.Data.Value;
RadioButtonHit.Checked = sampleResponse.CacheHit;
RadioButtonMiss.Checked = !sampleResponse.CacheHit;
proxy.Close();
}
catch (Exception)
{
proxy.Abort();
throw;
}
}
示例5: buttonTestWS_Click
/// <summary>
/// The button test w s_ click.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void buttonTestWS_Click(object sender, EventArgs e)
{
var proxy = new ServiceClient();
try
{
var resolutionInfo = proxy.GetAssemblyNames();
this.labelWebAssembly.Text = resolutionInfo.WebAssembly.Name;
this.labelWebPath.Text = resolutionInfo.WebAssembly.Path;
this.labelWebVersion.Text = resolutionInfo.WebAssembly.Version;
this.labelActivityAssembly.Text = resolutionInfo.ActivityAssembly.Name;
this.labelActivityPath.Text = resolutionInfo.ActivityAssembly.Path;
this.labelActivityVersion.Text = resolutionInfo.ActivityAssembly.Version;
}
catch (Exception)
{
proxy.Abort();
throw;
}
}
示例6: Correct
private void Correct()
{
string data;
bool success = false;
ServiceClient client = null;
try
{
client = new ServiceClient().GetProxy();
data = client.GetData(int.Parse(txtData.Text));
client.Close();
success = true;
}
finally
{
if (!success && client != null)
{
client.Abort();
}
}
ltlData.Text = data;
}
示例7: ShouldInvokeAverageExtensionWithService
public void ShouldInvokeAverageExtensionWithService()
{
const string Expected1 = "Stored 33, Average:33";
const string Expected2 = "Stored 44, Average:38.5";
const string Expected3 = "Stored 55, Average:44";
// Reset the static collection
AverageExtension.Reset();
// Self-Host Service1.xamlx using Named Pipes
var address = ServiceTest.GetUniqueEndpointAddress();
using (WorkflowServiceTestHost.Open("Service1.xamlx", address))
{
string result1;
string result2;
string result3;
// Use the generated proxy with named pipes
var proxy = new ServiceClient(ServiceTest.Pipe, address);
try
{
result1 = proxy.GetData(33);
result2 = proxy.GetData(44);
result3 = proxy.GetData(55);
proxy.Close();
}
catch (Exception)
{
proxy.Abort();
throw;
}
Assert.AreEqual(Expected1, result1);
Assert.AreEqual(Expected2, result2);
Assert.AreEqual(Expected3, result3);
}
}
示例8: BehaviorCanBeAddedViaConfig
public void BehaviorCanBeAddedViaConfig()
{
// Arrange
var serviceEndpoint = ServiceTest.GetUniqueEndpointAddress();
using (WorkflowServiceTestHost.Open(Constants.DefaultServiceXamlx, serviceEndpoint))
{
var proxy = new ServiceClient(ServiceTest.Pipe, serviceEndpoint);
try
{
// Act
var result = proxy.GetData(123);
proxy.Close();
// Assert
Assert.AreEqual("123", result);
}
catch
{
proxy.Abort();
throw;
}
}
}
示例9: LinkButtonTest_Click
protected void LinkButtonTest_Click(object sender, EventArgs e)
{
var proxy = new ServiceClient();
try
{
int num;
if (!Int32.TryParse(TextBoxNum.Text, out num))
{
LabelResult.Text = "Text cannot be converted to a number";
}
else
{
LabelResult.Text = proxy.GetData(num);
proxy.Close();
}
}
catch (Exception)
{
proxy.Abort();
throw;
}
}
示例10: ProcessInformationMessage
private void ProcessInformationMessage(MessageViewModel message)
{
MessageBox.Show(this, message.Text, message.Type, MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);
ServiceClient client = new ServiceClient();
try
{
client.MessageRead(message.ID);
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
finally
{
if (client != null)
{
// client.Dispose();
}
}
}
示例11: LoadMosaic
private static void LoadMosaic(MessageViewModel message)
{
ThreadPool.QueueUserWorkItem(delegate(object state)
{
try
{
ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
long mosaicID = client.GetMosaicIDForStation(Constants.MyStationID);
Constants.CurrentClientConfiguration.CurrentMosaic=mosaicID;
Constants.SaveDefaults();
Positions = client.GetPositionsForMosaic(mosaicID);
SavePositions(new List<PositionViewModel>(Positions));
MainWindow.Instance.LoadPositions(null);
client.SetStationStatus(Constants.MyStationID, "Positions Loaded, Now Playing");
}
catch (Exception)
{
}
ServiceClient client2 = new ServiceClient();
try
{
if (message != null)
{
client2.MessageRead(message.ID);
}
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client2.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client2.Abort();
}
});
}
示例12: GetMedia
private void GetMedia(MessageViewModel message = null)
{
ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
try
{
MediaListModel[] mediaList = client.GetMyMedia(Constants.MyStationID);
if (message != null)
{
client.MessageRead(message.ID);
}
ThreadPool.QueueUserWorkItem(delegate(object e4)
{
MediaListModel[] modelArray1 = mediaList;
for (int j = 0; j < modelArray1.Length; j++)
{
MediaListModel model1 = modelArray1[j];
}
});
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
finally
{
if (client != null)
{
// client.Dispose();
}
}
}
示例13: StartKeepAliveThread
private void StartKeepAliveThread()
{
ThreadPool.QueueUserWorkItem(delegate(object state)
{
this.PlayCurrentMosaic();
ThreadPool.QueueUserWorkItem(delegate(object e)
{
LoadMosaic(null);
});
while (true)
{
ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
try
{
client.ClientCredentials.Windows.ClientCredential.UserName = "admin";
client.ClientCredentials.Windows.ClientCredential.Password = "Green2o11";
if (client.SayHi(Constants.MyStationID) != "Hi there")
{
Console.WriteLine("Server Down");
}
else if (!this.CheckedForNewMessages)
{
this.GetMedia(null);
this.CheckedForNewMessages = true;
}
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
catch (Exception exception3)
{
Console.WriteLine("Server Down" + exception3.Message + exception3.StackTrace);
}
Thread.Sleep(0x2710);
}
});
}
示例14: SendMessageReceipt
private static void SendMessageReceipt(MessageViewModel message, bool updateList = true)
{
ServiceClient client = new ServiceClient();
try
{
client.MessageRead(message.ID);
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
if (updateList)
{
UnProcessedMessages.Remove(message);
}
}
示例15: StartKeepAliveThread
private void StartKeepAliveThread()
{
System.Timers.Timer timer = new Timer();
timer.Interval = (10000);
timer.Elapsed += delegate
{
ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);
try
{
if (client.ClientCredentials != null)
{
client.ClientCredentials.Windows.ClientCredential.UserName = "admin";
client.ClientCredentials.Windows.ClientCredential.Password = "Green2o11";
}
if (client.SayHiKey(new HardwareKey().Key) != "Hi there")
{
Console.WriteLine("Server_Down");
}
else if (!_checkedForNewMessages)
{
// this.GetMedia(null);
_checkedForNewMessages = true;
}
}
catch (TimeoutException exception)
{
Console.WriteLine("Got {0}", exception.GetType());
client.Abort();
}
catch (CommunicationException exception2)
{
Console.WriteLine("Got {0}", exception2.GetType());
client.Abort();
}
catch (Exception exception3)
{
Console.WriteLine("Server Down" + exception3.Message + exception3.StackTrace);
}
};
timer.Start();
}