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
- XmlProcessingInstruction.cs
- InternalResources.cs
- XslTransform.cs
- PasswordDeriveBytes.cs
- COM2ComponentEditor.cs
- ProgressiveCrcCalculatingStream.cs
- BaseTemplateBuildProvider.cs
- sqlinternaltransaction.cs
- MetadataProperty.cs
- Deflater.cs
- TextOnlyOutput.cs
- Frame.cs
- CryptoApi.cs
- ProxyManager.cs
- CanExecuteRoutedEventArgs.cs
- DataSourceView.cs
- DataControlFieldCollection.cs
- WebResponse.cs
- DataSourceBooleanViewSchemaConverter.cs
- InvalidDataException.cs
- TimeSpan.cs
- EncoderExceptionFallback.cs
- SqlDeflator.cs
- TypedLocationWrapper.cs
- CompilerTypeWithParams.cs
- ISFClipboardData.cs
- TypographyProperties.cs
- CodeCommentStatementCollection.cs
- SRGSCompiler.cs
- XmlMembersMapping.cs
- DataGridViewRowEventArgs.cs
- QueueProcessor.cs
- DataServiceCollectionOfT.cs
- ObjectRef.cs
- ToolStripSystemRenderer.cs
- x509utils.cs
- HashAlgorithm.cs
- SingleStorage.cs
- ServicePoint.cs
- DBCSCodePageEncoding.cs
- CodeAttributeDeclaration.cs
- SizeChangedInfo.cs
- WriteLineDesigner.xaml.cs
- CheckPair.cs
- FontStretch.cs
- RuntimeHandles.cs
- AdPostCacheSubstitution.cs
- SqlErrorCollection.cs
- Parameter.cs
- Pointer.cs
- DelegateSerializationHolder.cs
- ColumnHeaderConverter.cs
- WebPartExportVerb.cs
- GZipUtils.cs
- ManipulationDevice.cs
- ExtendedTransformFactory.cs
- ContainerUIElement3D.cs
- TypefaceMetricsCache.cs
- HttpListenerRequest.cs
- LineInfo.cs
- Menu.cs
- WebControlParameterProxy.cs
- CompModSwitches.cs
- PseudoWebRequest.cs
- RuntimeIdentifierPropertyAttribute.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- ExpressionWriter.cs
- UniqueConstraint.cs
- Int16Storage.cs
- DataKeyPropertyAttribute.cs
- Overlapped.cs
- Model3D.cs
- filewebrequest.cs
- DiscoveryEndpointElement.cs
- SafeRightsManagementSessionHandle.cs
- SqlFacetAttribute.cs
- StructuredTypeInfo.cs
- ServiceActivationException.cs
- BuildDependencySet.cs
- DataTableMappingCollection.cs
- CreateUserWizardStep.cs
- DataColumnCollection.cs
- PageVisual.cs
- AssemblyBuilderData.cs
- MsmqTransportReceiveParameters.cs
- PackageStore.cs
- Workspace.cs
- DescendantOverDescendantQuery.cs
- XmlText.cs
- NoneExcludedImageIndexConverter.cs
- ValueExpressions.cs
- SmtpLoginAuthenticationModule.cs
- RTLAwareMessageBox.cs
- Attributes.cs
- ToggleProviderWrapper.cs
- PathFigureCollection.cs
- ZipIOLocalFileHeader.cs
- ResourceWriter.cs
- XMLSchema.cs
- CodeMethodInvokeExpression.cs