|
The hanging that you are seeing is caused by a deadlock. The Form.Closing event is calling Thread.Join . I'm sure you are well aware that this call blocks until the thread has terminated gracefully. You are blocking the UI thread until the worker thread completes. But, the worker thread may be (and likely is) attempting to call Control.Invoke which blocks until the UI thread has completed its execution of the specified delegate. So if the Form.Closing event blocked the UI thread and the worker thread is trying to marshal something onto it then you have yourself a nice little deadlock. Now, depending on the exact timing of things you may not see this deadlock everytime, but I'm willing to bet that you'll see it most of the time.
|
|
|
|
|
Yes, thats exactly it.
I've decided to solve the problem by setting the Worker thread as a BackGround Thread. Althought this seems to alter the ThreadState from the Enumed values to a numeric value, I decided to deal with it. It works fine now.
Thanks for the response and explanation though.
|
|
|
|
|
Consider the following code
byte[] message = new byte[40];
message[4] = (byte)'S';
message[5] = (byte)'S';
message[6] = (byte)'T';
message[7] = (byte)'A';
message[8] = (byte)'R';
message[9] = (byte)'T';
message[10] = (byte)'C';
message[11] = (byte)'S';
int retval = myStream1.Write(message);
This code is a C# code myStream1 is an object of a COM component, What would be equivalent code in VC++
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
replace
byte[] message = new byte[40]
with
byte message[40];
the rest should be the same.
Edit:
Probably should toss in Zeromemory(message,40) to clear the buffer.
i.e.:
byte message[40];
ZeroMemory(message,40);
message[4] = (byte)'S';
message[5] = (byte)'S';
message[6] = (byte)'T';
message[7] = (byte)'A';
message[8] = (byte)'R';
message[9] = (byte)'T';
message[10] = (byte)'C';
message[11] = (byte)'S';
|
|
|
|
|
A BYTE[40] . A byte is a byte, or 8 bits.
Note that how you're doing this now is not a very effective means. You should take a look at the Encoding class. Since you obvious are dealing with ASCII characters, use the ASCIIEncoding class to convert a string to a byte[] array. The way you're doing it works, but could be tedious to maintain.
If you're asking how you'd marshal this, you could return a byte[] from your managed code. The CCW (COM-Callable Wrapper) would use [retval] LPBYTE, more than likely. That's not automation compliant, however. For true OLE Automation, you might consider marshaling this as a SAFEARRAY (UnmanagedType.SafeArray).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry i was not very clear what i wanted to ask...
actually i was not very clear what i wanted to ask either.
Any ways, proper question is this way, if i am passing Byte[] array as a parameter to a COM component what would be the input datatype in the COM component written in VC++?
I figured out that the input paramter is a VARIENT type
defined as something like this.
VARIENT vtParam;
vtParam.vt = VT_ARRAY | VT_UI1;
vtParam.parray =
Thanx for your reply.
Do you have any idea about how C# datatypes would be represented in VC++ COM, above is one example similarly strings in VB is BSTR in VC++ COM.
Any reference would be usefull.
Thanx again.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Since the VTYPE is VT_ARRAY | VT_UI1 , you would pass an array of bytes, or LPBYTE .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
exactly!
Thanx.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Hi, can somebody give me a little push in the right direction in how to read
the property tag 'makernote' for canon camera's.
I've read the exif description on
http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
but I don't know how to read the ifd format and extract the tags i need...
I have no problem reading the propertytags, I can read all the tags I need
except the makernote. In my case it's the canon makernote I want to read
(shootingmode etc.)
|
|
|
|
|
You can get the properties of an EXIF image file (JPEG) using the Image.PropertyItems property easily enough. The format of those properties, however, you must parse yourself. While you said you can already read these, I'd still like to mention an article here on CodeProject, Photo Properties[^]. It's a popular article and a good read if you're doing this in C#.
For the format of the makernote property, see http://www.exif.org/makernotes/SanyoMakerNote.html[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You might want to supply us with the Exception and the line that it occured on!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello is there any function of "strtod" in c#
i wil try Convert.ToDouble(); and double.parse();
it will throw Exception if any character occur in string but in vc it will not throw exception
char *string, *stopstring;
double x;
string = "3.1415926This stopped it";
x = strtod( string, &stopstring );
printf( "string = %s\n", string );
string = 3.1415926This stopped it
strtod = 3.141593
Stopped scan at: This stopped it
i will required it urgent
Tayyab
|
|
|
|
|
Take a look at double.TryParse .
|
|
|
|
|
I could be wrong (haven't tried it), but I don't think double.TryParse will work for you.
You could always write a quick little function for doing this yourself though. For example,
private double ParseString(string theString)
{
const char decimalPoint = '.';
int numDigitChars = 0;
bool foundDecimalPoint = false;
foreach(char ch in theString)
{
if(char.IsNumber(ch))
numDigitChars++;
else if(ch == decimalPoint && !foundDecimalPoint)
{
foundDecimalPoint = true;
numDigitChars++;
}
else break;
}
if(numDigitChars > 0)
return double.Parse(theString.Substring(0, numDigitChars));
else return 0;
}
...
string myDoubleString = "3.1457helloWorld";
double dbl = ParseString(myDoubleString);
Console.WriteLine(dbl);
#include "witty_sig.h"
|
|
|
|
|
Hello is there any function of strtod in c#
i will required it urgent
Tayyab
|
|
|
|
|
Convert.ToDouble(string)
Regards,
Björn Morén
Stockholm, Sweden
|
|
|
|
|
I am putting together an application that will sit in the systray.
To view the application window the user double clicks the systray icon, or right clicks and selects the necessary context menu option. When the user has finished looking at the application they would then minimise via a minimise button or the form minimise button.
Sounds simple enough, to handle the window state I have this very simple function
private void WindowControl()
{
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.WindowState = FormWindowState.Minimized;
}
}
There are two problems I am coming across, which I believe may be related :
1) When the application starts, the systray icon is display but a little application bar is also shown just above the start button.
2) When the user maximises the application bar disappears, the form is shown, when the user minimises the application bar reappears.
Basically I am looking for a way to completly hide the minimised application bar, to help this post a make a little more sense the following URL points to a screenshot of the problem (17k):
http://24601.net/images/bar.bmp
Thanks
M
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
At first i must say that i'm not familiar with using systray icons and so.
But regarding the description of your problem i think the Form.Hide method could help. Try to call it when you minimize and call Form.Show when you maximize your application.
|
|
|
|
|
Hi, I'm looking for a plug-in for Visual Studio .NET which can rename class and variable names safely and deeply. For example if I have a member variable in the class named binaryFormatter and I want to rename it to _binaryFormatter for instance, or I have a class named MyClass and I want to rename it to MyRenamedClass, the plug-in to rename all the occurrences safely. Anybody heard about some plug-in that can do this?
|
|
|
|
|
All I've ever used is Replace under the Edit menu...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In Visual Studio 2005 (codename "Whidbey"), they are adding refactoring. I believe there is a commercial plugin for VS.NET 2003. Just google for "refactoring" and "VS.NET" or something similar.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
I'd like to write/read the properties of file information in window.
for example, when i have choosen any file, then click the right button. i can see properties in context menu.
generally there are three tabs ( general, security, summary etc)
information of general tab can extract the FileInfo Class.
but i don't have any idea how to extract or write the summary info.
they have information of title, author, description etc.
So how could I deal with this information?
please help!!
thanks.
|
|
|
|
|
see description of StgOpenStorageEx and IPropertyStorage in MSDN
|
|
|
|
|
Hi,
I am really thank your response.
but i'm afraid i cannot find any clue in msdn although i found it.
so. could you give some examples? also i'd like to develop this fuction by c#. is it possible?
|
|
|
|
|
HRESULT FileDocProps::ReadProps(String* fileName, Guid fmtid, IList* props)
{
CStringW swFileName(fileName);
FMTID iidFmtID;
SetGUID(iidFmtID, fmtid);
CComPtr<IPropertySetStorage> spPropSetStg;
CComPtr<IPropertyStorage> spPropStg;
HRESULT hr = S_OK;
hr = StgOpenStorageEx(
swFileName,
STGM_READ | STGM_SHARE_EXCLUSIVE,
STGFMT_ANY,
0, NULL, NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&spPropSetStg));
if (FAILED(hr)) return hr;
hr = spPropSetStg->Open(
iidFmtID,
STGM_READ | STGM_SHARE_EXCLUSIVE,
&spPropStg);
if (FAILED(hr)) return S_OK;
CComPtr<IEnumSTATPROPSTG> spEnum;
bool isANSI = false;
short codePage = 0;
hr = GetCodePage(spPropStg, codePage, isANSI);
if (FAILED(hr)) return hr;
bool isUnicode = codePage == 0x04B0;
hr = spPropStg->Enum(&spEnum);
if (FAILED(hr)) return hr;
STATPROPSTG sps;
while (spEnum->Next(1, &sps, NULL) == S_OK)
{
PROPSPEC pss;
PROPVARIANT pvs;
pss.ulKind = PRSPEC_PROPID;
pss.propid = sps.propid;
hr = spPropStg->ReadMultiple(1, &pss, &pvs);
if (FAILED(hr)) continue;
try
{
String* name = sps.lpwstrName ? new String(sps.lpwstrName) : 0;
Object* v = PropVarToObject(pvs, codePage);
PropInfo pi((int) pss.propid, name, v);
props->Add(__box(pi));
}
catch(...)
{
}
PropVariantClear(&pvs);
CoTaskMemFree(sps.lpwstrName);
sps.lpwstrName = NULL;
}
return S_OK;
}
|
|
|
|