Hello,
lets assume we have a plugin dll based on the following class:
Question 1: How can I make the dll wait for any user interaction in form (without freezing) ?
Question 2: How can I interact bewteen form and dlls, e.g. exchanging data between both code parts and reacting on user inputs in form within dll ?
lets assume we have a plugin dll based on the following class:
My Code:
internal Class CustomDll()
{
private async Task<bool> Form()
{
Form1 _form = new();
_form.textBoxString = "....";
_form.Show();
bool task = await _form.WaitAsync();
if(task) _form.Close();
return task;
}
public void CustomDll()
{
Form();
//Here dll should wait for user reaction in form ?!
//ToDo:
//Proceed with dll initialization, if button 1 is pressed in Form, abort dll initialization if button 2 is pressen in form
//Problem:
//Form reakts on button press but dll is always initialized
}
//Other stuff
}
public partial class Form1 : Form
{
public string textBoxString = string.Empty;
private bool acceptflag = false;
private bool declineflag = false;
private readonly ManualResetEvent mre = new ManualResetEvent(false);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = textBoxString;
}
private void accept_Click(object sender, EventArgs e)
{
acceptflag = true;
}
private void decline_Click(object sender, EventArgs e)
{
declineflag = false;
}
public async Task<bool> WaitAsync()
{
var task = await Task.Run(() => WaitForButtonPressed());
return task;
}
public bool WaitForButtonPressed()
{
while (true)
{
if (acceptflag) return true;
if (declineflag) return false;
}
}
}
Question 1: How can I make the dll wait for any user interaction in form (without freezing) ?
Question 2: How can I interact bewteen form and dlls, e.g. exchanging data between both code parts and reacting on user inputs in form within dll ?