Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# callback using delegate

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CallbackUsingDelegateDemo : MonoBehaviour {

	public delegate void WorkCompletedCallBack(string result);

	public void DoWork(WorkCompletedCallBack callback){
		bool isWorkDone;

		//do work here

		isWorkDone = true;

		if (isWorkDone)
			callback ("yes work done successfully...");
		else 
			callback ("sorry work not done...");
	}

	void Start(){
		WorkCompletedCallBack workResultCallback = ShowWorkResult;
		DoWork (workResultCallback);
	}

	//this is the callback which is called when the work is done in DoWork()
	public void ShowWorkResult(string result){
		Debug.Log (result);
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: select distinct linq mvc 
Csharp :: select range in list c# 
Csharp :: asp.net core authorization default policy 
Csharp :: C# 1 minute delay 
Csharp :: how-to-add-new-column-with-value-to-the-existing-datatable 
Csharp :: csharp Console.Read(); 
Csharp :: how to add event function from code in wpf 
Csharp :: c# standard microphone decibels 
Csharp :: tailwind right 
Csharp :: c# find comma in text and remove 
Csharp :: C# one line method 
Csharp :: monegame deltatime 
Csharp :: Screen.lockcursor unity 
Csharp :: c# get index of item in list 
Csharp :: persian datapicker 
Csharp :: flat view player movement script 
Csharp :: Comparing Arrays using LINQ in C# 
Csharp :: multi case in c# 
Csharp :: c# query string builder 
Csharp :: convert list to datatable c# 
Csharp :: load a form from button c# 
Csharp :: c# how to get a file path from user 
Csharp :: How to change ListBox selection background color 
Csharp :: print text c# unity 
Csharp :: how to pass function as paraemter of another function pythpn 
Csharp :: unity GUI TextField enter 
Csharp :: dotnet add package 
Csharp :: how to create class in c# 
Csharp :: c# interface property 
Csharp :: change a positive number to negative or a negative number to positive 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =