|
George_George wrote: I am interested how volatile will impact write?
The effect is that every write will be done.
For example, in this code:
for (int i = 0; i <= 1000; i++) x = i;
If the x variable is declared as volatile, the code is guaranteed to perform the loop and write every single value in the loop to the variable. If it's not volatile, the compiler could optimize away the entire loop, replacing it with simply:
x = 1000;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Great Guffa!
You let me know new things.
regards,
George
|
|
|
|
|
I have to access to a filde in a column(record) in data grid when click on the column.(in c#)
hello
modified on Friday, May 16, 2008 8:10 AM
|
|
|
|
|
post this in a forum not here
Sacha Barber
- Microsoft Visual C# MVP 2008
- Codeproject MVP 2008
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
|
I know this is not C# but I figure there's more likely to be people in this forum that have played with PowerShell.
I've been experimenting with a couple of scripts to set folder permissions and I'm getting nowhere fast.
I've tried this from here http://chrisfederico.wordpress.com/2008/02/01/setting-acl-on-a-file-or-directory-in-powershell/[^]:
$acl = Get-Acl c:\temp
$permission = "domain\user","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl c:\temp
and this from here http://technet.microsoft.com/en-us/magazine/cc194419.aspx[^]:
#ChangeACL.ps1
$Right="FullControl"
#The possible values for Rights are
# ListDirectory, ReadData, WriteData
# CreateFiles, CreateDirectories, AppendData
# ReadExtendedAttributes, WriteExtendedAttributes, Traverse
# ExecuteFile, DeleteSubdirectoriesAndFiles, ReadAttributes
# WriteAttributes, Write, Delete
# ReadPermissions, Read, ReadAndExecute
# Modify, ChangePermissions, TakeOwnership
# Synchronize, FullControl
$StartingDir=Read-Host "What directory do you want to start at?"
$Principal=Read-Host "What security principal do you want to grant" `
"$Right to? `n Use format domain\username or domain\group"
#define a new access rule.
#note that the $rule line has been artificially broken for print purposes.
#it needs to be one line. the online version of the script is properly
#formatted.
$rule=new-object System.Security.AccessControl.FileSystemAccessRule
($Principal,$Right,"Allow")
foreach ($file in $(Get-ChildItem $StartingDir -recurse)) {
$acl=get-acl $file.FullName
#Add this access rule to the ACL
$acl.SetAccessRule($rule)
#Write the changes to the object
set-acl $File.Fullname $acl
}
For the second one I get this error when trying to apply it to an inetpub folder:
Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
At C:\Documents and Settings\kmcfarlane\My Documents\Development\ChangeACL.ps1:29 char:21
+ $acl.SetAccessRule( <<<< $rule)
Set-Acl : The security identifier is not allowed to be the owner of this object.
At C:\Documents and Settings\kmcfarlane\My Documents\Development\ChangeACL.ps1:32 char:10
+ set-acl <<<< $File.Fullname $acl
For the first script I just get the first part of that error. Any ideas?
Kevin
|
|
|
|
|
This would probably be a better question in the Operating System/ Sysadmin forum as I think there's probably more PowerShell users there.
|
|
|
|
|
There are more eyes in this forum and nothing turned up when I did a search on PowerShell in that forum, so I thought I'd try here.
Kevin
|
|
|
|
|
I handle a lot of images (about 500) in my application. These Images do I present in PictureBoxes that is dynamically inserted form top to bottom In a TabControl.
My program uses about 1 GB memory when I present all these Pictureboxes. I need a way to handle this better. I’ve searched for a custom control that handle Images but haven’t found one.
_____________________________
...and justice for all
APe
|
|
|
|
|
Ditch the pictureboxes, they suck. Create your own control. The way I did this, was the store my images in memory as JPEGs ( in a stream, using the Save method on the Bitmap class ) and I decompress them as they become visible and compress them again as they go from view.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I agree - PictureBoxes suck!
I'll try to create my own control for this. Feels like there should be a conrtol for this somewhere, but ok - I'll try to do my own.
_____________________________
...and justice for all
APe
|
|
|
|
|
Hello everyone,
I'd like to describe thoroughly my current scenario but it'd get a little bit verbose and perhaps misleading.
Let's say the main thread is queuing items to load and another thread should be loading asynchronously these items.
My main question is about the performance of creating and disposing of several FileStream objects, used to load files asynchronously several times in a row.
If you were to create a producer/consumer queue bound to async load files from hard-disk, how would you go? Would the disposal and creation of FileStream objects be of concern for you?
Thanks in advance!
Rob
|
|
|
|
|
You will be bound by the disk I/O at that point, so it will depend on how much work your doing with that stream. It might make more sense to use a memory stream and when your done, quickly dump that to disk.
I'd probabyl use MSMQ for my process list and have an external service pick up those messages to do the processing. Using MSMQ allows you to seperate out the functions of accepting work and doing work. The messages will also be persisted during failures by MSMQ, so it also gives you a safe guard.
I haven't looked at it much atall, but I think WCF can use MSMQ for it's message delivery medium. If you decide to go the route of seperating the processes, take a look at WCF as the communication mechanism.
|
|
|
|
|
Hi,
It has already been said that disk I/O will most likely be your performance bottleneck anyway, making object allocation / garbage collection a non-issue from a performance point of view.
However, disposing of file streams is in my experience often critical - as the physical file will stay open (and possibly locked) until the stream is disposed (or Close()d, which is equivalent if I remember correctly - either of them kills the Win32 file handle). Unless you're the only one touching the files, this can cause problems. I routinely wrap any file I/O in using blocks when possible, in order to minimize file lock durations.
In similar scenarios I usually just enqueue what needs to be done in a Queue<my_job_type> and dequeue it from a worker thread (locking the Queue when enqueuing or dequeueing). Usually I use a Queue<my_result_type> for the results from the worker thread.
Note: The normal restriction on only locking private stuff applies, of course. Your queues should not be visible outside of your class - if people in other classes (as would be expected) enqueue things to do and dequeue results, you wrap those operations (and queue lengths or HasWorkToDo and HasResults properties or whatever feels appropriate) in methods and properties of your own class. User code calls your en-/dequeueing methods (which use lock blocks), not the ones of the actual Queues.
I usually raise an event as well whenever I have enqueued stuff to the results queue, but beware that naïve users of your class may run into problems when they touch UI stuff from the event handler if they forget to Invoke() them properly (as the event will be raised from another thread than the UI thread). You should document that if your class isn't strictly internal.
Later,
--
Peter
|
|
|
|
|
First, thanks for your feedback.
I realize I've been a bit too vague in my initial post; however your suggestions reflect what I initially suspected.
Let me clarify a bit. I'm currently working on a 3D game and I've created a texture loader using the producer / consumer queue pattern. Depending on the view distance and the player position, I load and unload landscape textures from hard disk. I assumed (wrongly) that loading textures from another thread would be non-blocking for the main thread; this was not the case, since upon testing I was experiencing hiccups.
In another forum I read that perhaps an asynchronous loading would generally perform better (i.e. no hiccups). Seeing as I'm bound to load many textures per loader usage, I was curious to know about the performance of FileStream objects. I know they have to be correctly disposed; I'm not sure how the loader would behave when there are many concurrent asynchronous locks - if there's such a thing.
I know some testing would pretty much answer, but I thought that having some feedback, some first-hand experience on the matter would save me some time (which is never enough!).
Thanks again for any further advice,
Rob
PS: For any of you interested, some game screenshots can be found in the Gallery section of www.darkmana.com[^]
|
|
|
|
|
we'll be making an appointment schedulling for doctors.. it should display a table:
columns - doctor's name
rows - time slots
everytime we'll enter a new appointment, it will be displayed in the table.. can somebody help us??
|
|
|
|
|
sorry, whats the exact problem?
Tiefe Brunnen muss man graben wenn man klares Wasser will,
tiefe Wasser sind nicht still.
|
|
|
|
|
how can we make that appointment table?
|
|
|
|
|
hi mjee,
I think you want to store doctor Name and Appointment time in each row.If am i right,then make a table(in databsse) which contains the column DoctorName(Text Type) and AppointmentTime(Date time Type)
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
do you want to show it like a matrix?
| Dr. 1 | Dr. 2 | Dr. 3 |
...
09:00 | Mr. 1 | ---- | ----- |
09:30 | ----- | Mr. 2 | ----- |
...
Der Staat mit der niedrigsten Geburtenrate ist nicht die Bundesrepublik, sondern der Vatikan.
|
|
|
|
|
You can make a class the inherits from DataTable:
and make an initializing method where you put som ething like
TableName = <tablename>, add columns and dump to xml.
you can load it next time, and put it as GridView datasource.
|
|
|
|
|
Can I suggest you start out by having a good think about your database. It is the core of any application like this and unless you get this bit right early on you will struggle to enhance the system.
To get you started I would initially approach this with 3 tables.
Doctor
======
DoctorId - INT - NOT NULL - IDENTITY - PRIMARY KEY
DoctorName - NVARCHAR(200) - NOT NULL
(You can add other columns here later as needed)
Surgery
=======
SurgeryId - INT - NOT NULL - IDENTITY - PRIMARY KEY
SurgeryName - NVARCHAR(200) - NOT NULL
(Other columns here too eg/ opening times)
Appointment
===========
AppointmentId - INT - NOT NULL - IDENTITY - PRIMARY KEY
DoctorId - INT - FOREIGN KEY (Doctor)
SurgeryId - INT - FOREIGN KEY (Surgery)
AppointmentDateTime - DATETIME
(Other columns here if necessary)
That should get you started on the Db structure, and easily allows you to pull out all records for a particular doctor, or surgery, to display in a grid.
|
|
|
|
|
hi
I m developing a desktop application in streaming media using C#.
I m doing different opertions in it using multithreading like User Login, searching information from Database, searching and playing video file etc.
I m also capturing Live video from Webcam and displaying it on the window of my application. But the problem is that when I put the code of Live video capturing and preveiwing in Thread,it doesn't work i.e it doest not caputer n display the live video.
so tell me that is multithreading not possible in streaming media or there is some techniques of multithreading for it?
Plz reply me ASAP
Regards
B!z
|
|
|
|
|
its possible, but you have to ensure threadsafety, say, by using a circular buffer or similiar.
Hope this helps, Good luck
|
|
|
|
|
I'm coding a program like this in .Net 3.0. When you load a XML data. Its elements, texts, attributes will be populated on the Tree View and its full content in Text Box. I used XDocument(System.Xml.Linq) to make it faster. But now When I select a node from the Tree View, I want to highlight the line of XML code in the Text Box which contain that node. Any solution for this ? Help me, pls. Thank you.
modified on Friday, May 16, 2008 2:01 AM
|
|
|
|
|
Personally I would make a class that inherits from TreeNode and store the corresponding XML Code in it. When you select this TreeNode you can search in the Textbox for that string an highlight it.
Hope this helps
Tiefe Brunnen muss man graben wenn man klares Wasser will,
tiefe Wasser sind nicht still.
|
|
|
|