Skip to content

Can this be used in Console app? #37

@airadam

Description

@airadam

I've been trying to use this library in a .NET 7.0 Windows console app, but even after registering a simple delegate against ClipboardChanged, I can't get it to fire at all. As the initial documentation describes using it in VS with the Designer, I thought I'd better check - can I expect it to work at all in my use case, or will it only work in a Forms app or similar?

using System;
using WK.Libraries.SharpClipboardNS;

namespace ExampleApp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Starting.");
            var clipboard = new SharpClipboard();
            clipboard.ClipboardChanged += ClipboardChanged;

            while(true)
            {
            }
        }

        private static void ClipboardChanged(Object sender, SharpClipboard.ClipboardChangedEventArgs e)
        {
            Console.WriteLine("Change detected.");
            Console.WriteLine(e.Content.ToString());
        }
    }
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions