Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- namespace dIRC7
- {
- public static class IRCClipBoard
- {
- #region Declarations
- private static string Data;
- private static string NewData;
- #endregion
- public static void AddDataToClipboard(string Text)
- {
- if (String.IsNullOrEmpty(Data))
- {
- if (String.IsNullOrEmpty(Text)) { return; }
- Data = Text;
- Thread ClipboardThread = new Thread(_ClipboardWaiter);
- ClipboardThread.SetApartmentState(ApartmentState.STA);
- ClipboardThread.Start();
- }
- else
- {
- //Thread currently running
- NewData = Text;
- }
- }
- private static void _ClipboardWaiter()
- {
- bool bSuccess = false;
- while (!bSuccess)
- {
- // load clipboard data untill it actually loads.
- try
- {
- if (!String.IsNullOrEmpty(NewData))
- {
- Clipboard.SetText(NewData);
- }
- else
- {
- Clipboard.SetText(Data);
- }
- bSuccess = true;
- Data = null;
- NewData = null;
- break;
- }
- catch
- {
- Thread.Sleep(500);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement