|
While the code snippet isn't clear at all, having one Form influence/use something that resides in another Form is a common need, and there are some perfect solutions, all object-oriented. The keywords static and public are not the key to a solution, Dave's tip is.
systemerror121 wrote: without opening a new form?
The short answer is: there isn't a single proper way that does involve a new Form1, since any new Form1 will be different (similar but not identical) to the one you really want.
|
|
|
|
|
Hi
I am developing a clinic management software and I want to ask what's the best way to save and read email templates in order to use as default formatted text in the email for appointment reminder
|
|
|
|
|
Plain-Text is the absolute gold standard for sending mass emails. If you can't make it look good in plain-text there is a good chance your recipients won't read it. The second best is to use HTML. If you choose html you can use XSLT.
|
|
|
|
|
Can you please explain
So you mean I have to save the script in the sql server then retrieve it? How?
|
|
|
|
|
I guess you were wondering about the XML => HTML transform.
Store the XML in the server(or generate it on the fly) and then use
XSLT (EXtensible Stylesheet Language Transformations) to generate HTML/XHTML.
I bug
|
|
|
|
|
With code. What are you having a problem with? Do you not know how to use SQL? And I don't think he mentioned SQL. You could store the email templates in your project settings. Or in an XML file. Or in text files. Or in strings. However you like.
|
|
|
|
|
Use text files with parameters with some kind of delimiter. Then use string.replace on the text. If you were super cool you would send a VCalendar item as an AlternateView.
Dear %PATIENTNAME%,
We are sorry to inform you that you have %MONTHS% months to live. Please be prompt with your payment of %BALANCE%.
Kind Regards,
Dr. U. R. Screwed
How you figure out what the parameters you need to replace are for each type of message depends a lot on the rest of your design.
|
|
|
|
|
I always use 'mock-up' e-mailtemplates; I create a html file, which is basically the e-mail with variable names in them. Then I use a streamreader to read the file, replace all the occurrences of my variables with the actual values, and sent it out. Hope this helps.
"My personality is not represented by my hometown."
|
|
|
|
|
If I let a MessageBox to show in the timer event , it will show several messageBoxs, so I think that every one timer event in a new thread, right? How the timer run?
|
|
|
|
|
That depends on which Timer you're using. You can find them in multiple namespaces, like System.Windows.Forms, System.Timers, System.Threading, ... Which one are you using?
|
|
|
|
|
I donot know the differences between these four timers, I often use the timer in the namespace System.window.forms
|
|
|
|
|
Your question is difficult to understand- are you asking how you should implement a timer that will show a message box?
Windows forms timer events are called on the UI thread via the message pump. The Threading timers are not.
|
|
|
|
|
They're all different... http://msdn.microsoft.com/en-us/magazine/cc164015.aspx[^]
System.Windows.Forms.Timer = Runs in your UI thread, and is part of the message loop. If your GUI is running slowly, this timer will become inaccurate. If you run a long loop on the GUI thread that blocks user input, it'll block this too. Not only will it be inaccurate, but if it falls behind, it will actually just skip any ticks it missed.
System.Timers.Timer = Runs in its own thread, and triggers events on a background thread. You can use its Synchronizing object to put its events on the GUI thread if you want, and that'll make it work basically just like the S.W.F.Timer, except that it won't skip ticks.
System.Threading.Timer = Similar to the System.Timers.Timer, but gives you finer control and is a little more complicated to use.
|
|
|
|
|
The System.Windows.Forms.Timer control does not use a seperate thread to raise it's events. It's always going to use the application message pump to raise the event on the UI thread. Since it's using the message pump, the time that you actually see the event fired won't be entirely accurate.
The other timers use a seperate thread to call back your code, though the implementations of what you get back and how the timers behave vary slightly.
|
|
|
|
|
|
hmm... the timer event is triggered with the interval you specified. So as long as you don't disable it after the first event it will keep on executing the code. got nothing to do with threads
|
|
|
|
|
I want make Button in c# windowsForms export DataGridView Table to dbase IV.
How can i doo that?
Someone can help me plz ?
|
|
|
|
|
Hi,
I write some application that need to get new bitmap every 50 millisecond and store it on some bitmap collection.
When the size of the bitmap collection is 300 - the application remove all the bitmap and will collect the new bitmap again.
I see that on this case the GC will run more often - and i want to make somehow less running of the GC.
How can i do it ?
Thanks.
|
|
|
|
|
Advice I see very often is to let GC do it's job as it wants, because you're not smarter than it is.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
Yanshof wrote: store it on some bitmap collection
So long as it's referenced (stored) somewhere it will not be eligible for collection.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
There is only one good way to reduce the GC activity, and that is by reducing the need for memory due to the creation of new objects all the time. So get a smarter approach to whatever it is you want to achieve, or reduce the size of your objects, or reduce your need for objects, or recycle them. Recycling is a very effective means, but it isn't always easy as it works best for lots of objects of the same size; it also puts lifecycle management in your hands (as it was before GC-based languages got popular).
If you are creating synthetic bitmaps, recycling could be rather easy; if OTOH you load the bitmaps with existing (e.g. Bitmap.FromFile) it may not be practical.
|
|
|
|
|
Use unsafe code and allocate the space ahead of time for your bitmap collection. Don't use native objects.
|
|
|
|
|
Don't program in .Net.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
1. Just don't care.
2. Create a pool of recyclable bitmaps and manage them on your own.
3. Re-think your design
Remark: GC does the job it was designed for - it recognizes that your collection is not referenced by the program so it is collected. One point I don't understand is this: The collection you are talking about must be a temporary, otherwise it would not be gcollected. In that case, what other behaviour would you expect?
|
|
|
|
|
If i call 'dispose' at the end of use of each bitmap - I releasing the memory and i slow down the GC call - right ?
|
|
|
|