|
Daniel Turini wrote:
Beware that your static methods may need synchronization (the "lock" statement on C#), since they may be called from several threads and probably will work on global data.
I've tried a lock statement in the class...
public static void SomeStatic()
{
lock(this)
{
System.Windows.Forms.MessageBox.Show("Hello");
}
}
But it says you can't use 'this' from a static method. Any thoughts...
"De most compwehensive image seawch on de web." - Google in Elmer Fudd Language "But a fresh install - it's like having clean sheets" - Chris Maunder Lounge 3 Mar '03
Jonathan 'nonny' Newman Web Designer, Programmer, Lover, Visionary Leader...
Homepage [www.nonny.com] [^]
|
|
|
|
|
Just remove the lock from that, that static function call should be thread save already.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
Just remove the lock from that, that static function call should be thread save already.
Cheers
"De most compwehensive image seawch on de web." - Google in Elmer Fudd Language "But a fresh install - it's like having clean sheets" - Chris Maunder Lounge 3 Mar '03
Jonathan 'nonny' Newman Web Designer, Programmer, Lover, Visionary Leader...
Homepage [www.nonny.com] [^]
|
|
|
|
|
You can not use this keyword in static context. Try this:
Class YourClass
{
public static void SomeStatic()
{
lock(typeof(YourClass))
{
//some code operating on shared/global data
}
}
...
}
|
|
|
|
|
|
I've played around with it a bit. All it really is, is a way to plugin different exception handlers into a standard framework. That being said, it would be really cool to just plugin different managers that send the exception data to an e-mail address or a SQL Server or an MSMQ stack or something else...
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
I need a Url Combo like ComboBox that contains a collection of strings and while tyaping that should resize automatically and display the matching entries.
Its hard to improve perfection!!!
|
|
|
|
|
I tried to use masked edit AcitveX Control provided by Microsoft using C#.But I can't get the input through "Text" property of the control.
Please show me the problem.
Thank
|
|
|
|
|
http://www.compona.com/WikiEngine/WikiPageViewer.ascx?ID=46
you can use our free .net maskedit..
//Roger
|
|
|
|
|
I'm trying to access a dll from another company, and I am able to do so in VB6 and VB.net, but I can't seem to get it right in c#. Am I doing something wrong in my dllimport? I could write the app in vb.net, but I would prefer c#.
the vb.net version: (working)
-------------------
Private Declare Function eftlink Lib "c:\projects\ser3\eftlink.dll" Alias "EFTLink"(ByVal ncmd As Short, ByVal pszmsg As String) As Short
Call eftlink(1, "'ADR','030319','170900',123456,1111,00,1234567,1234,0" & vbCr)
the vb6 version: (working)
----------------
Private Declare Function eftlink Lib "c:\projects\ser3\eftlink.dll" Alias "EFTLink" _
(ByVal ncmd As Integer, ByVal pszmsg As String) As Integer
Call eftlink(1, "'ADR','030319','170900',123456,1111,00,1234567,1234,0" & vbCr)
My c# version: (not working)
--------------
[DllImport("eftlink.dll", EntryPoint="EFTLink")]
private static extern short EftLink (short ncmd, string pszmsg);
result = EftLink(1,"'ADR','030319','165000',123456,4567,00,1234567,1234,0\n");
Thanks,
Kristof
|
|
|
|
|
Hello there.
I just want to ask if you got the same.
When I start my Applications written in C# .NET and I take
a look in the Task Manager, they always use more than 10 MB RAM.
They are usual Windows.Forms applications which aren't very complex.
The *.exe File is around 50 KB and I compiled it with code optimization on.
Can someone tell me if this depends on a foult on my side or is it
just because of the .NET Framework ?
A little Program should not need so much memory I think ....
|
|
|
|
|
yep, thats pretty much the minimum size - its the .net runtime...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Mine are about the same ranging from 7 to 11 MB. Debug versions seem to require about a little than this. You can see why seasoned hardcare programmers are reluctant to switch over to the .net languages. I've always believed that if the workload can go on the programmer to spare the end user of bloated software, slow response etc.. then it should. On the other side of the coin if you don't get with the program you will be left behind (eventually).
Art
|
|
|
|
|
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
peace
|
|
|
|
|
Anonymous wrote:
I heat America
I thought oil heated America?
Paul Watson Bluegrass Cape Town, South Africa
Macbeth muttered:
I am in blood / Stepped in so far, that should I wade no more, / Returning were as tedious as go o'er
DavidW wrote:
You are totally mad. Nice.
|
|
|
|
|
lol
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
aaawww... arent u the nice lil hippy.
don't worry, America heats u too!
and proofread your anti-american comments from now on please. now you dont just look ignorant, but stupid as well. a deadly combination, even for un-informed peace junkies.
-613 "Code Poet"
"Real programmers don't work from 9 to 5. If any real programmers are around at 9am it's because they were up all night."
|
|
|
|
|
I have got an unhandled exception ,Who can tell me what's meaning of
it ,thanks
Here is something about the exception :
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at PersonalLib.Form1.Main() in f:\c#\windowsapi\api\windowsapplication7\form1.cs:line 120Application“[964] WindowsApplication7.exe”has exited with code 0 (0x0).
|
|
|
|
|
Hi, another quick question. I've only just started playing around with threads and the documentation with VS doesn't tell me much. So here's the problem (actually it's more a minor niggle):
I have a program which has to make thumbnails from a bunch of images, the thumbnails work fine, but they take a while when there are a lot of images, so I decided the solution was to run the thumbnail making in the background using a thread. My problem is that it is possible to switch to another directory and another bunch of images before the first thread is finished. The program doesn't actually seem to mind, but it does slow down while it is presumably executing several threads at once. So I thought the right thing to do is check if a thumbnail producing thread is running and stop it before starting a new one (since the user has lost interest in the current set of thumbnails by selecting a different directory, it doesn't matter if it doesn't ever get finished). So I tried this:
<br />
if (thd_thumbs.IsAlive)<br />
{<br />
thd_thumbs.Abort();<br />
}<br />
thd_thumbs = new Thread(new ThreadStart(this.run_thumbs));<br />
thd_thumbs.Start();<br />
But that doesn't work and the program crashes with a 'System.OutOfMemoryException' and 'Error creating window handle'. Without the if clause it works, but slows down as before. So what's the right way to do this?
|
|
|
|
|
Wjousts wrote:
if (thd_thumbs.IsAlive)
{
thd_thumbs.Abort();
}
thd_thumbs = new Thread(new ThreadStart(this.run_thumbs));
thd_thumbs.Start();
thd_thumbs.Abort() simply forces a ThreadAbortException into your thread, you then have to wait until that Exception is completely handled before you can dispose of the thread safely.
I would suggest you put a try, catch (ThreadAbortException) structure in run_thumbs and when you catch the exception, simply start the thread over again (thd_thumbs.Start()).
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
In a windows form, I'm developing a file backup app with a Treeview/Listview pair that behaves like Windows Explorer, listing drives and folders in the treeview, and folders and files in the listview... each entry has a checkbox so I can keep track of what's been selected...
The listview only has an ItemCheck event, whereas the treeview contains BeforeCheck and AfterCheck events, and also the ability to determine whether the event was fired by a mouse or not. This really limits me because I need to differentiate between mouse-induced checks and code-induced checks, just like in the treeview.
Is there some way to obtain this functionality in the listview?
thanks.
|
|
|
|
|
Check Control.MouseButtons
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I'm trying to make an image list of thumbnails and I can take an image an convert it into a thumbnail using Image.GetThumbnailImage. Before getting the thumbnail I calculate what the dimensions should be so as to not distort the image (i.e. make the largest dimension equal to the corresponding dimension of the thumbnail and then scale the other dimension by the same amount), this works fine. The problem is that when I put an image like this into an ImageList control the ImageList takes it upon itself to stretch the image to completely fill it's image size and therefore screws up my careful scaling. There doesn't seem to be any way to turn off this behaviour so my only option seems to be to pad my thumbnails with white space so that they are the right size, but I don't know how to do this. Can anybody help?
Thanks
|
|
|
|
|
You will first need to take a look at the Bitmap class and also the Graphics class.
First you need to create a new bitmap and make it white:
Bitmap bmp = new Bitmap(w,h);<br />
<br />
using(Graphics g = Graphics.FromImage(bmp))<br />
{<br />
<br />
g.FillRectangle(Brushes.White,0,0,bmp.Width,bmp.Height);<br />
<br />
int x = (w - bmp.Width) / 2;<br />
int y = (h - bmp.Height) / 2;<br />
<br />
g.DrawImage(original_bmp,x,y);<br />
}<br />
<br />
<br />
I have not tested this, but it should give you an idea.
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thanks, that seems to work. The only odd thing was that I had to use DrawImage(img,x,y,width,height) otherwise it did strange things to the image, sometimes it appeared tiny, other time blown up. Very strange.
|
|
|
|