How can I transform method into an event?

jaYCee.1750jaYCee.1750 USMember ✭✭

Can anyone lend a help please? I'm really having trouble with this one... How do I make this method into an event?

(BarcodeScannerRenderer.cs)

void IScanSuccessCallback.barcodeDetected(MWResult result)
{
        if (result != null)
        {
            try
            {
                var scan = Element as BarcodeScannerModal;

                if (scan == null)
                    return;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
}

And pass the value of result into another class, specifically in here:

(BarcodeScanner.cs)

public async Task<object[]> GetResult()
    {
        TaskCompletionSource<object[]> tcs = new TaskCompletionSource<object[]>();
        scanPage.OnScanResult += async (result) =>
        {
            object[] scanResult = new object[2];
            SharedAppSettings.Sounds.PlayBeep();
            scanResult[0] = resultFinal.text;
            scanResult[1] = resultFinal.typeText;
            await PopupNavigation.PopAsync();

            tcs.SetResult(scanResult);
        };
        return await tcs.Task;
    }

Please, I really need your help. :-( If you ever wonder what type of Barcode Scanner I am using, it's Manatee Works Barcode Scanner.

Sign In or Register to comment.