All Projects → ghuntley → WeakEventListener

ghuntley / WeakEventListener

Licence: MIT license
The WeakEventListener allows the owner to be garbage collected if its only remaining link is an event handler.

Programming Languages

C#
18002 projects
powershell
5483 projects
shell
77523 projects

Projects that are alternatives of or similar to WeakEventListener

LaunchMapsPlugin
Launch External Maps Plugin for Xamarin and Windows
Stars: ✭ 49 (+96%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Ffimageloading
Image loading, caching & transforming library for Xamarin and Windows
Stars: ✭ 1,288 (+5052%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Open Source Xamarin Apps
📱 Collaborative List of Open Source Xamarin Apps
Stars: ✭ 318 (+1172%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Mvvmlight
The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Windows 10 UWP, Windows Presentation Foundation (WPF), Silverlight, Windows Phone.
Stars: ✭ 973 (+3792%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
vs-material-icons-generator
This plugin will help you to set material design icons to your Xamarin projects In Visual Studio.
Stars: ✭ 50 (+100%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Arcgis Runtime Samples Dotnet
Sample code for ArcGIS Runtime SDK for .NET – UWP, WPF, Xamarin.Android, Xamarin.iOS, and Xamarin.Forms
Stars: ✭ 274 (+996%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Faceoff
An iOS, Android and UWP app created in Xamarin.Forms that uses Microsoft's Cognitive Emotion API Services to compare facial expressions
Stars: ✭ 79 (+216%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
arcgis-runtime-demos-dotnet
Demo applications provided by the ArcGIS Runtime SDK for .NET Team
Stars: ✭ 51 (+104%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Simpleauth
The Simplest way to Authenticate and make Rest API calls in .Net
Stars: ✭ 148 (+492%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Plugin.audiorecorder
Audio Recorder plugin for Xamarin and Windows
Stars: ✭ 140 (+460%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Arcgis Toolkit Dotnet
Toolkit for ArcGIS Runtime SDK for .NET
Stars: ✭ 125 (+400%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Xamarin Demos
This repository contains the Syncfusion Xamarin UI control’s samples and the guide to use them.
Stars: ✭ 218 (+772%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Microsoft.maui.graphics
Stars: ✭ 160 (+540%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Connectivityplugin
Connectivity Plugin for Xamarin and Windows
Stars: ✭ 253 (+912%)
Mutual labels:  xamarin, uwp, xamarin-ios, xamarin-android
Plugin.NFC
A Cross-Platform NFC (Near Field Communication) plugin to easily read and write NFC tags in your application.
Stars: ✭ 113 (+352%)
Mutual labels:  xamarin, xamarin-ios, xamarin-android
Prototype.Forms.Controls
This sample app contains a random mixture of Xamarin/Xamarin.Forms controls, views, and functionality snippets that I've created.
Stars: ✭ 21 (-16%)
Mutual labels:  xamarin, xamarin-ios, xamarin-android
Xamarin.Plugin.ImageEdit
Image Edit Plugin for Xamarin
Stars: ✭ 52 (+108%)
Mutual labels:  xamarin, xamarin-ios, xamarin-android
XamarinIoTWorkshop
A workshop that demonstrates how to collect IoT data from a mobile device using a Xamarin app, aggregating the data to the cloud using Azure IoT Hub
Stars: ✭ 13 (-48%)
Mutual labels:  xamarin, xamarin-ios, xamarin-android
SKOR.UI
UI Controls for Xamarin.Forms
Stars: ✭ 56 (+124%)
Mutual labels:  xamarin, xamarin-ios, xamarin-android
XamUI
Xamarin UI Challenges 🏆
Stars: ✭ 57 (+128%)
Mutual labels:  xamarin, xamarin-ios, xamarin-android

Icon

WeakEventListener

The WeakEventListener allows the owner to be garbage collected if its only remaining link is an event handler. See https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/weak-event-patterns for more information; the wisdom found on that page is applicable for other platforms inc UWP, Xamarin.Mac, Xamarin.iOS & Xamarin.Android.

Supported Platforms

  • netstandard v1.1 (and up)

Installation

Installation is done via NuGet:

PM> Install-Package WeakEventListener

Usage

public class SampleClass
{
    public event EventHandler<EventArgs> Raisevent;

    public void DoSomething()
    {
        OnRaiseEvent();
    }

    protected virtual void OnRaiseEvent()
    {
        Raisevent?.Invoke(this, EventArgs.Empty);
    }
}

public void Test_WeakEventListener_Events()
{
    bool isOnEventTriggered = false;
    bool isOnDetachTriggered = false;

    SampleClass sample = new SampleClass();

    WeakEventListener<SampleClass, object, EventArgs> weak = new WeakEventListener<SampleClass, object, EventArgs>(sample);
    weak.OnEventAction = (instance, source, eventArgs) => { isOnEventTriggered = true; };
    weak.OnDetachAction = (listener) => { isOnDetachTriggered = true; };

    sample.Raisevent += weak.OnEvent;

    sample.DoSomething();
    Assert.True(isOnEventTriggered);

    weak.Detach();
    Assert.True(isOnDetachTriggered);
}

With thanks to

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].