Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / RetriableClipboard.cs / 1305376 / RetriableClipboard.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System.Threading; using System.Windows; using System.Windows.Media.Imaging; using System.Runtime.InteropServices; using System.Runtime; using System.Diagnostics; // The clipboard may be accessed by other processes. // RetriableClipboard retries several times before giving up. static class RetriableClipboard { const int retryCount = 10; const int sleepTime = 50; internal static IDataObject GetDataObject() { for (int i = 0; i < retryCount; i++) { try { return Clipboard.GetDataObject(); } catch (Exception err) { Trace.WriteLine(err.ToString()); if (Fx.IsFatal(err)) { throw; } Thread.Sleep(sleepTime); } } return null; } internal static void SetDataObject(object data, bool copy) { for (int i = 0; i < retryCount; i++) { try { Clipboard.SetDataObject(data, copy); return; } catch (Exception err) { Trace.WriteLine(err.ToString()); if (Fx.IsFatal(err)) { throw; } Thread.Sleep(sleepTime); } } } internal static void SetImage(BitmapSource image) { for (int i = 0; i < retryCount; i++) { try { Clipboard.SetImage(image); return; } catch (Exception err) { Trace.WriteLine(err.ToString()); if (Fx.IsFatal(err)) { throw; } Thread.Sleep(sleepTime); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System.Threading; using System.Windows; using System.Windows.Media.Imaging; using System.Runtime.InteropServices; using System.Runtime; using System.Diagnostics; // The clipboard may be accessed by other processes. // RetriableClipboard retries several times before giving up. static class RetriableClipboard { const int retryCount = 10; const int sleepTime = 50; internal static IDataObject GetDataObject() { for (int i = 0; i < retryCount; i++) { try { return Clipboard.GetDataObject(); } catch (Exception err) { Trace.WriteLine(err.ToString()); if (Fx.IsFatal(err)) { throw; } Thread.Sleep(sleepTime); } } return null; } internal static void SetDataObject(object data, bool copy) { for (int i = 0; i < retryCount; i++) { try { Clipboard.SetDataObject(data, copy); return; } catch (Exception err) { Trace.WriteLine(err.ToString()); if (Fx.IsFatal(err)) { throw; } Thread.Sleep(sleepTime); } } } internal static void SetImage(BitmapSource image) { for (int i = 0; i < retryCount; i++) { try { Clipboard.SetImage(image); return; } catch (Exception err) { Trace.WriteLine(err.ToString()); if (Fx.IsFatal(err)) { throw; } Thread.Sleep(sleepTime); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntityContainer.cs
- PolicyStatement.cs
- StyleTypedPropertyAttribute.cs
- Scalars.cs
- WebResourceAttribute.cs
- ComboBox.cs
- ImageMapEventArgs.cs
- BaseValidator.cs
- DrawingAttributeSerializer.cs
- TraceListener.cs
- SocketInformation.cs
- XmlSerializationReader.cs
- ObjectTag.cs
- ConnectionPoolManager.cs
- ErrorWrapper.cs
- TaskScheduler.cs
- XmlSchemaAttribute.cs
- ProcessThread.cs
- UriTemplatePathSegment.cs
- XmlChoiceIdentifierAttribute.cs
- HandledEventArgs.cs
- UnwrappedTypesXmlSerializerManager.cs
- FixUpCollection.cs
- ProfileServiceManager.cs
- IRCollection.cs
- RadioButton.cs
- ResourcesBuildProvider.cs
- CodeValidator.cs
- JsonFormatReaderGenerator.cs
- NullableDecimalMinMaxAggregationOperator.cs
- LoginName.cs
- EntityDesignPluralizationHandler.cs
- X500Name.cs
- KeyValueConfigurationCollection.cs
- XsdBuildProvider.cs
- ObjectViewEntityCollectionData.cs
- SchemaImporterExtensionsSection.cs
- WebReferencesBuildProvider.cs
- BoundsDrawingContextWalker.cs
- BitmapEffectvisualstate.cs
- XmlComment.cs
- SHA1Managed.cs
- XmlnsCompatibleWithAttribute.cs
- MembershipValidatePasswordEventArgs.cs
- OrderingInfo.cs
- IntranetCredentialPolicy.cs
- TrackingParameters.cs
- XPathSelfQuery.cs
- TextSpanModifier.cs
- _AutoWebProxyScriptWrapper.cs
- InputEventArgs.cs
- WsdlInspector.cs
- XPathParser.cs
- BitmapDownload.cs
- SqlColumnizer.cs
- recordstate.cs
- ColumnResult.cs
- DesignRelation.cs
- EventDescriptor.cs
- NumericUpDown.cs
- DocumentCollection.cs
- GenericWebPart.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- OrderPreservingSpoolingTask.cs
- MsmqIntegrationBinding.cs
- ReadingWritingEntityEventArgs.cs
- ZipIOExtraFieldElement.cs
- HttpCookieCollection.cs
- NotFiniteNumberException.cs
- MultiView.cs
- CustomAttributeFormatException.cs
- RuleSettingsCollection.cs
- BooleanStorage.cs
- StylusTip.cs
- DataGridViewColumnDesigner.cs
- IgnoreDataMemberAttribute.cs
- ScaleTransform.cs
- StringExpressionSet.cs
- OperandQuery.cs
- PackWebResponse.cs
- ToolBarPanel.cs
- InitializationEventAttribute.cs
- Atom10FormatterFactory.cs
- CollectionExtensions.cs
- LingerOption.cs
- SqlMethodCallConverter.cs
- SiteMapHierarchicalDataSourceView.cs
- PartialCachingAttribute.cs
- ImageListDesigner.cs
- RequestCachingSection.cs
- EventMappingSettingsCollection.cs
- AuthenticationConfig.cs
- UiaCoreTypesApi.cs
- SafeCryptHandles.cs
- LZCodec.cs
- mda.cs
- LocatorPart.cs
- ReadOnlyDictionary.cs
- cookiecollection.cs
- DesignerTransactionCloseEvent.cs