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
- ApplyImportsAction.cs
- SecuritySessionServerSettings.cs
- FilterElement.cs
- ComponentCodeDomSerializer.cs
- ArgumentNullException.cs
- DataGridAddNewRow.cs
- ReversePositionQuery.cs
- SqlLiftIndependentRowExpressions.cs
- EraserBehavior.cs
- __Filters.cs
- LoadMessageLogger.cs
- DocumentOrderQuery.cs
- FixUpCollection.cs
- WindowsGraphics2.cs
- relpropertyhelper.cs
- BamlWriter.cs
- ToolStripGrip.cs
- MediaPlayer.cs
- WeakHashtable.cs
- TypeDelegator.cs
- EntityDataSourceChangedEventArgs.cs
- ActivityWithResult.cs
- PEFileEvidenceFactory.cs
- _Win32.cs
- RawStylusInput.cs
- CodeTypeParameterCollection.cs
- WindowsStatic.cs
- ImageMapEventArgs.cs
- Header.cs
- UriScheme.cs
- ProgressBar.cs
- Events.cs
- ContainerActivationHelper.cs
- TreeNode.cs
- XmlParserContext.cs
- InterleavedZipPartStream.cs
- BlobPersonalizationState.cs
- DetailsViewPagerRow.cs
- OuterGlowBitmapEffect.cs
- HtmlValidatorAdapter.cs
- ToolStripPanelCell.cs
- ResXResourceReader.cs
- ButtonChrome.cs
- DesignerTransaction.cs
- GridViewColumnCollection.cs
- DataGridViewLinkCell.cs
- ChtmlImageAdapter.cs
- BaseDataListComponentEditor.cs
- mediaeventargs.cs
- InternalConfigHost.cs
- ProxySimple.cs
- RegexRunnerFactory.cs
- ClrProviderManifest.cs
- HttpDateParse.cs
- MulticastNotSupportedException.cs
- LocalizableAttribute.cs
- _NestedSingleAsyncResult.cs
- ObjectParameter.cs
- RecordBuilder.cs
- FullTextLine.cs
- WebBrowser.cs
- BufferModeSettings.cs
- ExtendedPropertyCollection.cs
- BinaryMethodMessage.cs
- AxWrapperGen.cs
- WpfMemberInvoker.cs
- StrokeRenderer.cs
- WizardPanel.cs
- DateTimeConverter2.cs
- Message.cs
- Boolean.cs
- CacheAxisQuery.cs
- HtmlTextArea.cs
- FactoryGenerator.cs
- AutomationPatternInfo.cs
- XmlNamespaceMapping.cs
- Matrix.cs
- BorderGapMaskConverter.cs
- StorageComplexTypeMapping.cs
- NotificationContext.cs
- _SpnDictionary.cs
- ProcessProtocolHandler.cs
- AsyncPostBackErrorEventArgs.cs
- XmlSerializerSection.cs
- WebEventTraceProvider.cs
- UIAgentCrashedException.cs
- Attributes.cs
- ValueProviderWrapper.cs
- HtmlContainerControl.cs
- PropVariant.cs
- SecurityHelper.cs
- ReadOnlyNameValueCollection.cs
- DeleteIndexBinder.cs
- RequestSecurityTokenResponse.cs
- QilIterator.cs
- MetadataFile.cs
- Int64AnimationBase.cs
- HtmlInputControl.cs
- PersonalizationEntry.cs
- PenContext.cs