|
The application can't be idle if the UI thread is currently executing code, such as "waiting" for database results or reading a file. An idle state of an application indicates that the STA on which the application was started is not currently processing. So, something else is reseting your cursor. The only other way to process queued notification messages on the UI thread is to call Application.DoEvents as I mentioned above.
If you want the cursor to be the WaitCursor for the whole app, make sure you use Cursor.Current and not the Cursor property of the control. Since the control also contains a Cursor property, use System.Windows.Forms.Cursor to specify the class just to be sure.
As far as this vs. Win32, all this wraps the functions defined in the Win32 APIs. Much - it not most - of the Framework does encapsulate the Win32 APIs.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
The application can't be idle if the UI thread is currently executing code, such as "waiting" for database results or reading a file.
A thread get idle when waiting for a database ot reading a file. It have always been that way, trust me
And... I don't call Application.DoEvents() anywhere what so ever in my application, but the cursur still automatically changes to an arrow.
Heath Stewart wrote:
If you want the cursor to be the WaitCursor for the whole app, make sure you use Cursor.Current and not the Cursor property of the control.
Yes, I do know that, I just dont think you know why I wrote as I did
It was just for testing, you know, and I found it funny that when the application was processing stuff, it changed the hurglass cursor to an arrow.
Thanks for your attempt to help but I guess you dont know whats happening, no more than I do...
It's probably just another quirck of the .NET framework.
Heath Stewart wrote:
As far as this vs. Win32, all this wraps the functions defined in the Win32 APIs. Much - it not most - of the Framework does encapsulate the Win32 APIs.
Yes, but have you ever used the Win32 API with C++?
So much more control.
- Anders
Money talks, but all mine ever says is "Goodbye!"
My Photos[^]
|
|
|
|
|
Our application makes an extraordinary amount of database calls, even through remoting and never goes idle, hence we never have a problem with the wait cursor resetting. These calls are typically made in the STA thread. The only time I have had problems with the wait cursor resetting is when I make asynchronous calls.
Anders Molin wrote:
Yes, but have you ever used the Win32 API with C++?
Since Windows 3.1. Still do, although most development is in a couple .NET languages, mostly C#.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
A thread that waits for something is idle, and the cpu does other things in the mean time
Well, I think we think of "idle" as different things...
- Anders
Money talks, but all mine ever says is "Goodbye!"
My Photos[^]
|
|
|
|
|
Heath,
I'm sure you know this, but it's good to show everyone the preferred way to work with Wait Cursors in C#:
using (Cursor.Current = Cursors.WaitCursor)
{
}
Regards,
Alvaro
"I do" is both the shortest and the longest sentence in the English language.
|
|
|
|
|
Hello fellow code poets,
I am attempting to sign an assenbly with a strong name the VS.NET way using the KeyFileAttribute in the AssemblyInfo.cs file.
I have read over MS documentation in the Framework SDK, Knowledgebase and the commented instructions in the AssemblyInfo.cs.
And of course all three sources show you something a little different.
This is the basics of my error:
http://support.microsoft.com/default.aspx?scid=kb;en-us;328379&Product=sql2k
I have tried to use these three examples I was given and they have all failed.
[assembly: AssemblyKeyFile(@"..\\..\\tempKey.snk")]
[assembly:AssemblyKeyFileAttribute("tempKey.snk")]
[assembly: AssemblyKeyFile("..\\..\\tempKey.snk")]
I have placed the key in the project directory, Visual Studio Projects/Project directory and in the bin and I am still failing it seems to get the right location.
Can any one help?
Thanks.
Jarrad D.
|
|
|
|
|
Make sure you have generated a key and put it in the projects directory using
sn.exe -k KeyFile.snk Keep this file safe and do not share it.
Also, when using the literal specifier "@", do not escape your backslashes like you are in the first example. The location of the file is relative to the build path. VS.NET builds everything relative to bin\(Debug|Release) by default, so your first and third examples are correct (assuming the key pair file is generated correctly). The third will not work unless building your project from the project directory (possible using the csc.exe command-line compiler).
Just as a side note, it doesn't matter where you put assembly attributes, so long as they're part of a source file being compiled into your assembly.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the help Heath.
The tempKey.snk is my key and I have tried all my examples having put my key in the bin\ it still will not compile without the errror.
Any other ideas?
Thanks.
Jarrad
|
|
|
|
|
The bigger question was about how it was generated. Did you use "sn.exe -k filename"? It has to contain at least the private key. "-k" will generate a key pair, which contains the public and private key.
Also, what exactly is the exception you're getting? Specifics are always more helpful.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
In my first post I linked to a MS KB article that contains the compile error I am receiving.
"Cryptographic failure while signing assembly '...\WindowsApplication1.exe' -'Error reading key file 'key.snk' -- The system cannot find the file specified."
I did use the -k when creating my key.
Thanks again.
Jarrad
|
|
|
|
|
Just to isolate if the problem is with the file, or with the file location, try to put the full file path ("c:\\project\\blablabla\\tempKey.snk").
Trying to make bits uncopyable is like trying to make water not wet.
-- Bruce Schneier
By the way, dog_spawn isn't a nickname - it is my name with an underscore instead of a space. -- dog_spawn
|
|
|
|
|
Daniel,
It was with literal location. I got it to work. Is it normal to use ("c:\\project\\blablabla\\tempKey.snk")? In the examples it made it sound like this ex. [assembly: AssemblyKeyFile("..\\..\\tempKey.snk")] was what told the compiler to look for it in the bin.
Anyway thanks.
|
|
|
|
|
No, this tells the compiler to look for it in the second parent directory above the build directory, which is bin\Debug or bin\Release. That means that "..\\..\\" is the directory with the project file (.csproj, for a C# project, for example).
If you can, it's often better to use a relative path so that you don't have to worry about where you copy the project directory to and having to keep the same structure (which is especially important when managing the code using a version control system like Visual SourceSafe or CVS.
The directory structure should look like this if you use "..\\..\\KeyFile.snk" in your [assembly: AssemblyKeyFileAttribute] :
Project Directory
+-bin
| +-Debug
| | +-MyApp.exe
| | +-MyApp.pdb
| +-Release
| +-MyApp.exe
+-AssemblyInfo.cs
+-Form1.cs
+-KeyFile.snk
+-MyApp.csproj
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks again for all the great information.
You guys have been very helpful.
Hope I can return the favor sometime.
|
|
|
|
|
Hello,
I managed to use several network Windows API inside C# code with DllImport (such as GetAdaptersInfo) but the GetIfTable seems to be a little bit different.
My problem is that i need to obtain the data in the MIB_IFROW structure and it gets filled with zeros instead of the corect information.
Here is the source code of a simple console application where the problem occurs:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Runtime;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
public class Win32Import<br />
{<br />
public static uint ERROR_NOT_SUPPORTED = 50;<br />
<br />
public const int MAXLEN_IFDESCR = 256;<br />
public const int MAXLEN_PHYSADDR = 8;<br />
<br />
public const int MAX_INTERFACE_NAME_LEN = 256;<br />
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]<br />
public struct MIB_IFTABLE<br />
{<br />
public uint dwNumEntries;<br />
public MIB_IFROW table;<br />
};<br />
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]<br />
public struct MIB_IFROW<br />
{<br />
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_INTERFACE_NAME_LEN)]<br />
public string wszName;<br />
<br />
public uint dwIndex;<br />
public uint dwType;<br />
public uint dwMtu;<br />
public uint dwSpeed;<br />
public uint dwPhysAddrLen;<br />
<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXLEN_PHYSADDR)]<br />
public byte[] bPhysAddr;<br />
<br />
public uint dwAdminStatus;<br />
public uint dwOperStatus;<br />
public uint dwLastChange;<br />
public uint dwInOctets;<br />
public uint dwInUcastPkts;<br />
public uint dwInNUcastPkts;<br />
public uint dwInDiscards;<br />
public uint dwInErrors;<br />
public uint dwInUnknownProtos;<br />
public uint dwOutOctets;<br />
public uint dwOutUcastPkts;<br />
public uint dwOutNUcastPkts;<br />
public uint dwOutDiscards;<br />
public uint dwOutErrors;<br />
public uint dwOutQLen;<br />
public uint dwDescrLen;<br />
<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXLEN_IFDESCR)]<br />
public byte[] bDescr;<br />
};<br />
<br />
<br />
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public extern static void<br />
CopyMemory_Int(<br />
ref uint Destination,<br />
ref byte Source,<br />
int Length<br />
);<br />
<br />
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public extern static void<br />
CopyMemory_MibIfrow(<br />
ref MIB_IFROW Destination,<br />
ref byte Source,<br />
int Length<br />
);<br />
<br />
[DllImport("iphlpapi.dll")] public extern static uint<br />
GetIfTable(<br />
byte[] pIfTable,<br />
ref uint pdwSize,<br />
bool bOrder<br />
);<br />
}<br />
<br />
<br />
class Class1<br />
{<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
uint nBufLen = 0;<br />
uint nError;<br />
<br />
nError = Win32Import.GetIfTable(null, ref nBufLen, true);<br />
if (nError == Win32Import.ERROR_NOT_SUPPORTED)<br />
{<br />
return;<br />
}<br />
<br />
byte[] IfTableBuffer = new byte[nBufLen];<br />
nError = Win32Import.GetIfTable(IfTableBuffer, ref nBufLen, true);<br />
if (nError != 0)<br />
{<br />
return;<br />
}<br />
<br />
uint dwNumEntries = 0;<br />
int byteCount = 0;<br />
<br />
Win32Import.CopyMemory_Int(ref dwNumEntries, ref IfTableBuffer[byteCount], 4);<br />
byteCount += 4;<br />
<br />
Win32Import.MIB_IFROW pIfRow = new Win32Import.MIB_IFROW();<br />
Win32Import.CopyMemory_MibIfrow(<br />
ref pIfRow,<br />
ref IfTableBuffer[byteCount],<br />
Marshal.SizeOf(pIfRow)<br />
);<br />
byteCount += Marshal.SizeOf(pIfRow);<br />
}<br />
}<br />
}<br />
If you are familiar with these C# API calls and think you can help me , you're welcome. Many thanks!
|
|
|
|
|
First, use the out keyword instead of ref in the first parameter of GetIfTable to avoid having to instantiate the structure. Not a big deal, but it is the correct declaration.
Also, you're MIB_IFROW structure is incorrect. First, the first string member is a WCHAR - a wide character (2 bytes). Therefore, your CharSet in the StructLayoutAttribute should be set to CharSet.Unicode . The UnmanagedType.ByValTStr will then cause the marshaler to use what the CharSet in the StructLayoutAttribute declares, namely a Unicode string (an array of WCHAR s).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
It works!
I didn't thought that this mistake would be the reason of the problems.
But it's logic as Unicode and ANSI characters don't have the same size.
Thank you very much!
|
|
|
|
|
I'm using a MonthCalendar control in a C# winforms application and have discovered that if you click the text above the calendar which displays the year, two scroll buttons appear to allow you to scroll through the years. The up button scrolls into the future and a new date is selected as each year is scrolled. The down button scrolls back in time, but instead of selecting a single new date, a date range is selected. Does anyone know of a method/property that can be adjusted to turn off this behaviour for the down scroll button? Thanks.
Chris Meech
We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton
VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler
|
|
|
|
|
If you don't want a range of dates to be selectable at all, set MonthCalendar.MaxSelectionCount to 1. If you only want a single date selected while changing dates, you could handle the MonthCalendar.DateChanged and select only the MonthCalendar.SelectionStart date.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
set MonthCalendar.MaxSelectionCount to 1.
I have the property set to a value of 1 already. I expect that this is a subtle bug I've stumbled across. The odd part is that for two seemingly similar actions, year/scroll-up or year/scroll-down, the control behaves differently.
Chris Meech
We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton
VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler
|
|
|
|
|
Chris Meech wrote:
I have the property set to a value of 1 already. I expect that this is a subtle bug I've stumbled across.
Hmm, you might be right. You could take a look at the Month Calendar Common Control (http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/monthcal/reflist.asp[^]) that the MonthCalendar encapsulates. Perhaps there's something you can do by extending the MonthCalendar and overriding WndProc to handle notification messages, though I don't really see any off-hand that would help, unfortunately.
Have you tried the method of handling the DateChanged event and simply setting the SelectionEnd to SelectionStart ? It's a bad hack, but I don't see why it wouldn't work.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
Have you tried the method of handling the DateChanged event and simply ...
I'll probably end up doing that, as this is purely a cosmetic kind of issue. I got bigger fish to fry at the moment as I try and get a WebService to connect and run queries from an Oracle database. But thanks for the suggestions.
Chris Meech
We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton
VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler
|
|
|
|
|
I am redesigning the UI for one of our data editors. I have an Infragistics ListBar main panel on the left(Dock=left), a slider (Dock=left), and a control area where the different edit controls are dynamically constructed(Dock=fill).
At design time I also added a second panel for groups. That panel and its' slider are Dock=left and marked Disabled, NOT Visible. I have one button on the main panel for opening the group selector whenever the editor wants to group items into a manageable group. I have tried numerous ways to make this group panel appear...all in vain. Here is my last attempt:
this.controlArea.Dock = DockStyle.None;
this.controlArea.Size = new Size(10, 10);
this.groupDisplay.Enabled=true;
this.groupDisplay.Visible = this.groupDisplay.Visible=false?true:false;
this.groupDisplay.Size = new Size(3, 453);
this.grpSplit.Enabled = true;
this.grpSplit.Visible= this.grpSplit.Visible=false?true:false;
this.controlArea.Dock = DockStyle.Fill;
this.Invalidate(true);
The panel does not become visible no matter what!!! Any suggestion would be appreciated.
Michael
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
You have a problem here:
this.groupDisplay.Visible = this.groupDisplay.Visible=false?true:false; You're setting Visible to false , not testing it. For that, use the == operator. In fact, just dump it all together and toggle the value with the following expression:
this.groupDisplay.Visible = !this.groupDisplay.Visible;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
DOH!
Guess I shouldn't code with only 4 hours of sleep.
Thanks Heath
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|