/// <summary> /// Initiates a synchronous DDE transaction, using the timeout value specified. /// If the timeout expires, an exception is thrown. /// </summary> /// <param name="item">Item name for which the transaction is executed.</param> /// <param name="data">Data to be exchanged during the transaction.</param> /// <param name="timeout">Specifies the maximum length of time, in milliseconds, that the client will wait for a response from the server application in a synchronous transaction.</param> public void StartTransaction(string item, string data, DWORD timeout) { Dde.CheckOwnerThread(); byte[] arDataBuffer = data != null?Encoding.ASCII.GetBytes(data) : null; DWORD dwResult = 0; using (DdeString dsItem = new DdeString(_dde, item)) { if (Dde.DdeClientTransaction(arDataBuffer, (uint)(arDataBuffer != null ? arDataBuffer.Length : 0), _handle, dsItem.Handle, 0, Dde.DdeTransaction.XTYP_EXECUTE, timeout, ref dwResult) == IntPtr.Zero) { throw new DdeException("Could start a DDE transaction.", _dde.GetLastError()); } } }