C#, C♯, C#相談室 Part53
at TECH
887:870
09/08/18 23:54:18
>>884
ソースをさらします。
サーバーがRunScriptというパケットを受け取ると実行される
void talk()
{
Thread t = new Thread(executeScript);
t.Start(this.remoteip);
}
private void executeScript(object data)
{
PythonEngine pe = new PythonEngine();
pe.deliverVarible("_self", this);
pe.deliverVarible("_target", target);
pe.deliverVarible("_remoteip", (string)data);
pe.execute("foo.py");
}
//リモートIPとManualResetEventが対になってる
static Dictionary<string, ManualResetEvent> ManualEvent = new Dictionary<string, ManualResetEvent>();
//foo.pyがwaitForSignalを実行すると呼び出させる
public void waitForSignal()
{
if (remoteip == null) return;
ManualEvent[remoteip].Reset();
ManualEvent[remoteip].WaitOne(Globals.script_wait_time);
}
//別スレッドから呼び出し
public void setSignal()
{
if (remoteip == null) return;
ManualEvent[remoteip].Set();
}
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
5015日前に更新/223 KB
担当:undef