python.net

How do I convert a VB delegate into a python event handler?

守給你的承諾、 提交于 2020-12-12 12:23:46
问题 I have to rewrite the following VB code that is subscribing to a delegate (event), into python, using python.net. Imports MtApi Public Class Form1 Private apiClient As MtApiClient Public Sub New() InitializeComponent() apiClient = New MtApiClient AddHandler apiClient.QuoteUpdated, AddressOf QuoteUpdatedHandler End Sub Sub QuoteUpdatedHandler(sender As Object, symbol As String, bid As Double, ask As Double) Dim quoteSrt As String quoteSrt = symbol + ": Bid = " + bid.ToString() + "; Ask = " +

How to subscribe to a .NET event in a python listener using pythonnet?

允我心安 提交于 2020-12-12 08:49:21
问题 I'm trying to make an event listener to subscribe to a tick (price) event from a FX trading application, using Python. The original application is a native 32-bit Windows app called MetaTrader4 . This does not have any API, so the mtapi bridge has been designed in .NET to allow other programming languages to interact with it. The application has some events defined, two of which are: QuoteUpdate and QuoteUpdated . So I would like to write a listener ( delegate ?) using python.net to subscribe

FreeLibrary returns true indefinitely

别说谁变了你拦得住时间么 提交于 2020-01-24 00:40:17
问题 Is there any reason why FreeLibrary would repetitively return true? I'm trying to unload some native dll from my process, so I'm getting it's handle and then calling FreeLibrary until the ref count goes to zero and so FreeLibrary returns false... but it never does: IntPtr pDll = DllLoadingImports.LoadLibrary(dllTounLoad); //throw if pDll == IntPtr.Zero while(DllLoadingImports.FreeLibrary(pDll)); The code runs and never returns. Also the process explorer shows the dll still loaded. More

Using C# Assemblies from Python via pythonnet

纵饮孤独 提交于 2020-01-22 12:08:06
问题 I am using Windows 7, 64-bit. I have managed to download and install pythonnet, so import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Form works fine. I have also downloaded and compiled/run a C# application which creates lots of assemblies. The application in question is ARDrone-Control-.NET. How can I use the generated DLL files from Python (and not just the built-in C# classes). Since I have never used C# (which is why I want to use the library from Python

Python for .NET: How to call a method of a static class using Reflection?

馋奶兔 提交于 2020-01-13 20:39:37
问题 I want to use a method of a static class. This is my C# code: namespace SomeNamepace { public struct SomeStruct { .... } public static class SomeClass { public static double SomeMethod { .... } } If it was a "normal" class I could use SomeMethod like lib = clr.AddReference('c:\\Test\Module.dll') from System import Type type1 = lib.GetType('SomeNamespace.SomeClass') constructor1 = type1.GetConstructor(Type.EmptyTypes) my_instance = constructor1.Invoke([]) my_instance.SomeMethod() But when

Python for .NET: How to call a method of a static class using Reflection?

妖精的绣舞 提交于 2020-01-13 20:39:05
问题 I want to use a method of a static class. This is my C# code: namespace SomeNamepace { public struct SomeStruct { .... } public static class SomeClass { public static double SomeMethod { .... } } If it was a "normal" class I could use SomeMethod like lib = clr.AddReference('c:\\Test\Module.dll') from System import Type type1 = lib.GetType('SomeNamespace.SomeClass') constructor1 = type1.GetConstructor(Type.EmptyTypes) my_instance = constructor1.Invoke([]) my_instance.SomeMethod() But when

Worker Thread Stops execution when it reaches at Using Block C# Windows form application

我们两清 提交于 2020-01-03 05:21:30
问题 This is how the demo windows form app looks like: And this is the implemented code: public partial class HornMorphoWindow : Form { private static dynamic _morpho; private static string _analyzeWord; private static Logger logger = LogManager.GetCurrentClassLogger(); public delegate void StatusDelegate(); public HornMorphoWindow() { InitializeComponent(); } private void HornMorphoWindow_Load(object sender, EventArgs e) { var splashScreen = new Splash(); // This is Splash Form splashScreen.Show(