Wednesday, November 27, 2019
The Dark Side of Application.ProcessMessages
The Dark Side of Application.ProcessMessages Article submitted by Marcus Junglas When programming an event handler in Delphi (like the OnClick event of a TButton), there comes the time when your application needs to be busy for a while, e.g. the code needs to write a big file or compress some data. If you do that youll notice that your application seems to be locked. Your form cannot be moved anymore and the buttons are showing no sign of life. It seems to be crashed. The reason is that a Delpi application is single threaded. The code you are writing represents just a bunch of procedures which are called by Delphis main thread whenever an event occured. The rest of the time the main thread is handling system messages and other things like form and component handling functions. So, if you dont finish your event handling by doing some lengthy work, you will prevent the application to handle those messages. A common solution for such type of problems is to call Application.ProcessMessages. Application is a global object of the TApplication class. The Application.Processmessages handles all waiting messages like window movements, button clicks and so on. It is commonly used as a simple solution to keep your application working. Unfortunately the mechanism behind ProcessMessages has its own characteristics, which might cause big confusion! What does ProcessMessages? PprocessMessages handles all waiting system messages in the applications message queue. Windows uses messages to talk to all running applications. User interaction is brought to the form via messages and ProcessMessages handles them. If the mouse is going down on a TButton, for example, ProgressMessages does all what should happen on this event like the repaint of the button to a pressed state and, of course, a call to the OnClick() handling procedure if you assigned one. Thats the problem: any call to ProcessMessages might contain a recursive call to any event handler again. Heres an example: Use the following code for a buttons OnClick even handler (work). The for-statement simulates a long processing job with some calls to ProcessMessages every now and then. This is simplified for better readability: {in MyForm:} à à WorkLevel : integer; {OnCreate:} à à WorkLevel : 0; procedure TForm1.WorkBtnClick(Sender: TObject) ; var à à cycle : integer; begin à à inc(WorkLevel) ; à à for cycle : 1 to 5 do à à begin à à à à Memo1.Lines.Add(- Work IntToStr(WorkLevel) , Cycle IntToStr(cycle) ; à à à à Application.ProcessMessages; à à à à sleep(1000) ; // or some other work à à end; à à Memo1.Lines.Add(Work IntToStr(WorkLevel) ended.) ; à à dec(WorkLevel) ; end; WITHOUT ProcessMessages the following lines are written to the memo, if the Button was pressed TWICE in a short time: - Work 1, Cycle 1 - Work 1, Cycle 2 - Work 1, Cycle 3 - Work 1, Cycle 4 - Work 1, Cycle 5 Work 1 ended. - Work 1, Cycle 1 - Work 1, Cycle 2 - Work 1, Cycle 3 - Work 1, Cycle 4 - Work 1, Cycle 5 Work 1 ended. While the procedure is busy, the the form does not show any reaction, but the second click was put into the message queue by Windows. Right after the OnClick has finished it will be called again. INCLUDING ProcessMessages, the output might be very different: - Work 1, Cycle 1 - Work 1, Cycle 2 - Work 1, Cycle 3 - Work 2, Cycle 1 - Work 2, Cycle 2 - Work 2, Cycle 3 - Work 2, Cycle 4 - Work 2, Cycle 5 Work 2 ended. - Work 1, Cycle 4 - Work 1, Cycle 5 Work 1 ended. This time the form seems to be working again and accepts any user interaction. So the button is pressed half way during your first worker function AGAIN, which will be handled instantly. All incoming events are handled like any other function call. In theory, during every call to ProgressMessages ANY amount of clicks and user messages might happen in place. So be careful with your code! Different example (in simple pseudo-code!): procedure OnClickFileWrite() ; var myfile : TFileStream; begin à à myfile : TFileStream.create(myOutput.txt) ; à à try à à à à while BytesReady 0 do à à à à begin à à à à à à myfile.Write(DataBlock) ; à à à à à à dec(BytesReady,sizeof(DataBlock)) ; à à à à à à DataBlock[2] : #13; {test line 1} à à à à à à Application.ProcessMessages; à à à à à à DataBlock[2] : #13; {test line 2} à à à à end; à à finally à à à à myfile.free; à à end; end; This function writes a large amount of data and tries to unlock the application by using ProcessMessages each time a block of data is written. If the user clicks on the button again, the same code will be executed while the file is still being written to. So the file cannot be opened a 2nd time and the procedure fails. Maybe your application will do some error recovery like freeing the buffers. As a possible result Datablock will be freed and the first code will suddenly raise an Access Violation when it accesses it. In this case: test line 1 will work, test line 2 will crash. The better way: To make it easy you could set the whole Form enabled : false, which blocks all user input, but does NOT show this to the user (all Buttons are not grayed). A better way would be to set all buttons to disabled, but this might be complex if you want to keep one Cancel button for example. Also you need to go through all the components to disable them and when they are enabled again, you need to check if there should be some remaining in the disabled state. You could disable a container child controls when the Enabled property changes. As the class name TNotifyEvent suggests, it should only be used for short term reactions to the event. For time consuming code the best way is IMHO to put all the slow code into an own Thread. Regarding the problems with PrecessMessages and/or the enabling and disabling of components, the usage of a second thread seems to be not too complicated at all. Remember that even simple and fast lines of code might hang for seconds, e.g. opening a file on a disc drive might have to wait until the drive spin up has finished. It doesnt look very good if your application seem to crash because the drive is too slow. Thats it. The next time you add Application.ProcessMessages, think twice ;)
Saturday, November 23, 2019
Free sample - Discussions on Psychological Theory. translation missing
Discussions on Psychological Theory. Discussions on Psychological TheoryPresent paper deals with the discussions of the psychological theory and its main principles. According to this theory, usage of drugs and peopleââ¬â¢s addiction to them can be explained by different factors. The first case under discussion is usage of drugs because of two main factors contributing it. They are reinforcement and personal problems. I completely agree that the positive reinforcement is one of the key factors, making people use drugs. Pleasurable sensations, accruing after drug usage is the main reason of the desire to get drugs again and again. That is why, all people who are addicted to drugs, explain their addiction by this reason. The next motivation for the drug abuse is problems in the emotional life. When people have certain emotional or personal troubles, such as problems in family or relationships, they suppose that drugs are the only way out that can help them to escape from reality. The next point under discussion is drug addiction due to the inadequate personality. People, having the features of the inadequate personality experience low self-respect and feel constant failure of life. As a result they are more apt to become addicted to drugs. I can not agree more with this fact, as in our life there are quite many examples when individuals who are not satisfied with their life try to change this situation with the help of drugs. They think that only under the influence of drugs they can feel more self-confident and successful. The final topic of drug abuse reasons is unawareness of people about the negative effects of such addicting and absence of will power. In this case, the factor of negative reinforcement occurs. Very often, people, suffering from unbearable pains start using drugs in order to decrease pain and unpleasant feelings. They do it without complete understanding of the results, as the only motivation for them is pain relief. Weak will power or its complete absence is very significant factor that should be mentioned. People who are lack of will power have more chances to get into drug dependence. For such people it is very difficult to resist the temptation of drug usage, especially when they are influenced by the friends who are already abused by drugs.
Thursday, November 21, 2019
Introduction to ICD Classification - Classification Systems (U2IP&DB) Essay
Introduction to ICD Classification - Classification Systems (U2IP&DB) - Essay Example e United States official system for assigning codes to procedures and diagnoses based on the World Health Organizations Ninth Revision, International Classification of Diseases (ICD-9)â⬠(MediLexicon, 2008, pg. 1). Four main steps are involved in the process of selecting the proper ICD-9-CM codes. These must be followed in detail in order to ensure that the diagnosis is accurately described by the code. The steps described in the following paragraph are necessary in order to establish the proper ICD-9-CM code (Pelaia, 2003, pg. 7). The first step in assigning the proper ICD-9-CM code is to ââ¬Å"review the medical record documentation in order to properly identify the terms that best describe the patientââ¬â¢s diagnosisâ⬠(Pelaia, 2003, pg. 8). The second step in assigning the proper code is to ââ¬Å"look up the terms that best describe the patientââ¬â¢s diagnosis in Volume 2 (the alphabetic index) and identify the ICD-9 code that best matches the diagnosisâ⬠(Pelaia, 2003, pg. 9). The third step in assigning the proper ICD-9-CM code is to ââ¬Å"look up the selected code in Volume 1 (the tabular list) to make the code selection. Careful attention should be paid to ââ¬Ëincludesââ¬â¢ and ââ¬Ëexcludesââ¬â¢ notes and other instructions in Volume 1â⬠(Pelaia, 2003, pg. 10). Finally, all information should be carefully reviewed and verified. It is extremely important for a medical coder or for a medical professional responsible for ensuring that the correct diagnostic codes are being recorded for the procedures performed at a medical facility is using an up-to-date code book. Failing to use a current code book can result in a variety of mishaps that can easily be avoided. If a person loses his or her current code book, it should be replaced immediately. First of all, it is essential that medical personnel keep proper records in order to stay compliant with legal regulations. Using an old code book could result in the wrong diagnosis being recorded for a patient which could
Tuesday, November 19, 2019
The Pros and Cons of Crowdsourcing Research Paper
The Pros and Cons of Crowdsourcing - Research Paper Example At the present, Oracle Corporation is facilitating the companies to use the influence of crowdsourcing to the various tasks of the company like that customer relationship management software program through a new enterprise. Regardless of the introduction of crowdsourcing potentials, a high-quality idea carries the menace of sneering at the source, making wrong way to the suitable sector, otherwise being deferred for a long time that it turns out to be useless. Increasingly companies across upright productions are making their way to crowdsourcing. In this scenario, eMarketer revealed in a business article that has proficiently utilized crowdsourcing as an imperative aspect of CSR programmes, almost 95% people say that it was at least somewhat important and effective approach to utilize. Additionally, a survey over 200 corporate executives was carried out in Fortune and almost 200 businesses stated the most helpful feature of crowdsourcing for their CSR program efforts. Whereas respo ndent frequently is inspired for the reason that they desire a specific product to become successful, businesses as well are able to offer incentives or rewards in the form of prizes to nonfinancial advantages for instance rank figures as stars, desired user status, a well-known fame on the Web site. Crowdsourcing is an emerging trend which has been used in various aspects and area of life. The purpose of this research is to study the concept of crowdsourcing and analyze the impacts of crowdsourcing in various disciplines of businesses and industrial framework. This research also analyzes the economic impacts of crowdsourcing. With the passage of time, the actual components of crowdsourcing were revealed by experiment and mistake. However, a number of corporations or individuals encompass a covert formula that they apply to guarantee constant accomplishment; whereas other people exercise the tried-and-true techniques those have been suggested by the professionals.
Sunday, November 17, 2019
Philips Kotler Marketing Management Essay Example for Free
Philips Kotler Marketing Management Essay Analyzing Consumer Markets Since marketing starts from the customer, it is of primary importance to understand the psyche of the customers and their buying motives. This chapter talks about the various behavioural patterns that govern the decision making process of a customer. A marketer needs to understand these factors affecting the customerââ¬â¢s purchase decisions so as to design an appropriate marketing strategy. Factors affecting Consumer Buying Behaviour 1. Cultural Factors a. Culture Frames traditions, values, perceptions, preferences. E.g. Child learning from family surroundings. b. Sub-culture Provides more specific identification and socialization. Include nationalities, religions, racial groups and geographic regions. c. Social Class ââ¬â Homogeneous and enduring divisions in a society which are hierarchically ordered. Members share similar tastes and behaviour. 2. Social Factors a. Reference Groups ââ¬â Have direct or indirect influence on personââ¬â¢s attitude and behaviour. Primary groups: regular interaction, e.g. family, friends, neighbours. Secondary groups: religious, professional, trade union groups. Aspirational Groups: ones that a person hopes to join. Dissociative groups: whose values or behaviour and individual rejects. b. Family ââ¬â Family of orientation: parents and siblings. Acquires orientation towards religion, politics and economics, sense of personal ambition, self worth and love. Family of procreation: spouse and children. More direct influence on buying behaviour. c. Roles and Status ââ¬â Role consists of activities a person is expected to perform. Each role carries a status. Marketers must be aware of the status symbol of each product. Chapter 6 Analyzing Consumer Markets 3. Personal Factors a. Age and Stage in the Life Cycle ââ¬â Tastes are age related. Markets should also consider critical life events or transitions. b. Occupation and Economic Circumstances ââ¬â Economic Circumstances like spendable income, savings, assets, debts, borrowing power etc affect consumption patterns. c. Personality and Self Concept ââ¬â Personality, set of distinguishing characteristics that influence his/her buying behaviour. Consumers match brand personality with their ideal self concept instead of their actual self concept. d. Lifestyle and Values 4. Psychological Factors a. Motivation: Freudââ¬â¢s theory of id, ego and super ego; Maslowââ¬â¢s need hierarchy theory; Herzbergââ¬â¢s two factor model. b. Perception: Process by which we select, organize and interpret information inputs. In marketing, perceptions are more important than reality. c. Learning ââ¬â Induces changes in behaviour arising from experience. Marketers can build demand by associating the product with positive drives. d. Memory ââ¬â Short term and long term memory. Build brand knowledge and brand recall as node in memory. Problem Recogniton Information Search Evaluation of Alternatives Purchase Decision Postpurchase Behaviour The Buying Decision Process Problem Recognition Customer recognises a need triggered by internal or external stimuli. Marketers need to identify circumstances that trigger needs. Information Search Two levels of involvement ââ¬â Heightened attention when person becomes more receptive to information about the product. At next level consumer may enter into active information search, looking for reading material, phoning friends etc. Evaluation of Alternatives Factors influencing a particular choice over the other include attitudes, beliefs and expectancy value. Purchase Decision Between purchase intention and purchase decision, 2 intervening factors come into play- Attitudes of others and Unanticipated situational factors. Marketers should understand that these factors provokeà risk and should provide information to reduce it. Post purchase Behaviour Marketers must monitor postpurchase satisfaction, postpurchase actions, and postpurchase product uses. Chapter 6 Analyzing Consumer Markets Trends Level of customer involvement Involvement Significant Insignificant Differences in Brands High Complex Buying Behaviour Low Variety Seeking Dissonance Reducing Habitual 1. Complex Buying Behaviour: When a customer purchases something for the first time. 2. Variety Seeking: Consumers will keep switching varieties just out of boredom. Eg- Biscuits. Marketer should keep introducing new products and display the product prominently. 3. Habitual: Buying the same thing out of habit and not out of loyalty. Distribution network should be excellent in this case. Maintain consistency in product and advertising. 4. Dissonance Reducing: In case of repeat purchase of same product.
Thursday, November 14, 2019
Plato Essay example -- essays research papers fc
One of the questions that has faced and continues to face some of the philosophers of the world is "What is reality?" Plato addresses this question in his doctrine, the Theory of Forms. In an attempt to answer this question, he explains what the Forms are and how they affect the way the world is observed. These so-called Forms are the basis of the reality we perceive. The question one must ask him or her self is what are these forms, where do they come from, and how do they affect us as a society. "A Platonic Form (Idea) is not a thought in someone's mind but something that exists per se as an immutable part of the structure of reality."(Luce, 99) This statement is the foundation of Plato's philosophy. What he is saying is that these forms are behind the way we see the world. In other words, they control the images and ideas that are presented to us. Two examples of such forms are ideal beauty and absolute goodness. When a person makes a comment like " That is a beautiful home." What is the difference between a beautiful home and a home that is not beautiful? This illustrates the point that Plato is attempting to make about the Forms functioning as a standard by which we compare the world to. In essence, these Forms serve as a measuring stick by which we make our judgements. In regards to the Form of absolute goodness, Plato describes this one as the all- powerful form. Here Plato suggests that the other Forms derive their meaning from the Form of absolute goodness. Some of the other Forms include Equality, circularity, Health and Justice. These forms cannot be seen nor can they be felt; however, they can be apprehended by the mind after suitable preparation and training (Luce, 100). These forms exist in everything we see, in all the decisions we make and it is these Forms that we perceive when we describe something as beautiful or right or even wrong. The Theory of Forms also has two significant underlying doctrines within its contents. The first one is the distinction between opinion and knowledge. One word that Plato uses to describe opinion is flawed. He explains that opinions are always changing due to anything from outside forces or simply just one's perception. For example, the people around can alter a person's opinion or even the type of room someone is in. External pressures are the cause of the variation in opinions ... ...tself (Stump, 62). In the Theory of Forms, Plato provides us with a possible answer to some of the questions that continually plague most people. The answer to the question "What is real" may never have a definitive answer. All one can do is to use the abilities given to him and try to arrive to their own conclusion based on what he or she knows. Whether the reality most of us perceive is true or not is difficult to determine. The Theory of Forms gives us a way of analyzing reality, but like all other doctrines it stops short of precisely defining reality. This inability to conclude the argument is the very same reason why this debate will continue on for as long as we live and probably our children and their children and so on. The pursuit of truth will continue to be the driving force behind the search for the answer to the question that can explain the significance of our existence. Myla Modert Plato 11/6/00 Works Cited Stumpf, Samuel Enoch. Socrates to Sartre: A History of Philosophy. 1988, McGraw Hill Publishing New York City. PP 58-62. Luce, J.V. An Introduction to Greek Philosophy. 1992, Thames an Hudson Ltd. London. PP 99-102
Tuesday, November 12, 2019
Nutrition Essay
Holozoic nutrition (Gr. holo means-whole ; zoikos means-of animals) is a method of nutrition that involves the ingestion of liquid or solid organic material, digestion, absorption and assimilation of it to utilize it. It includes taking in the complex substances and converting them into simpler forms. Example, proteins can be broken into amino acids. This method suggests phagocytosis where the cell membrane completely surrounds a food particle[pic] Parasitic Nutrition is a mode of heterotrophic nutrition where an organism (known as a parasite) lives on the body surface or inside the body of another type of organism (known as a host). The parasite obtains nutrition directly from the body of the host. Since these parasites derive their nourishment from their host, this symbiotic interaction is often described as harmful to the host. Parasites are dependent on their host for survival, since the host provides nutrition and protection. As a result of this dependence, parasites have considerable modifications to optimise parasitic nutrition and therefore their survival. Saprotrophic nutrition (pron.: /sà ¦prà µÃËtrÃâfà ªk/) is a process of chemoheterotrophic extracellular digestion involved in the processing of dead or decayed organic matter. It occurs in saprotrophs or heterotrophs, and is most often associated with fungi, for example Mucor and Rhizopus. The process is most often facilitated through the active transport of such materials through endocytosis within the internal mycelium and its constituent hyphae.[1] Autotrophic Nutrition The term autotroph has been derived from two Greek wards-auto means self and troph means nutrition. In this mode of nutrition, the organisms prepare their own food from simple raw materials like water, carbon dioxide and mineral salts in the presence of sunlight. Chlorophylls present in the chloroplast or green plants are the site of food production. Accordingly all green plants are the examples of this category. The process by which they synthesize food is known as photosynthesis. Some nongreen becteria like sulphur bacteria can use energy which they derive from some chemical reactions occurring in them. With this energy they manufacture their food. This process is called chemosynthesis. Thus the autotrophs include both the photosynthetic and che4mosynthetic organisms. Heterotrophic Nutrition The word heterotrophy has been derived from two Greek words-hetero means different and troph refers to nutrition of food. The organisms which derive their food from others are known as heterotrophic organisms. They depend for their food on other organisms, hence they are called consumers. All animals, human beings and non-green plans like fungi come under this category. They consume complex organic food prepared by autotrophs or producers and break it into simple from to derive nourishment. Thus the difference between heterotrophy and autotrophs is basically in the mode of production of food. Due to lack of chlorophyll, heterotrophs cannot synthesize their food while autotrophs can perform photosynthesis.
Subscribe to:
Posts (Atom)