) Explore the mysteries of event processing in the VB Series

Source: Internet
Author: User
Network College

Event is yoursCodeWhat is the main part of the weapons library, whether you use Visual Basic? 6.0, Visual Basic. NET 2002, Visual Basic. NET 2003, or visual basic 2005. Events are triggered by forms and controls, and your code processes these events. The initial application you wrote with Visual BasicProgramMost of them place a button on a form to process the click event. When you click this button at run time, some text is displayed in the prompt box. What is easier than this?

But how much do you really know about events? What will happen when you add an event handler to a class? In this article, based on the courseware I wrote for appdev, I will use various methods to demonstrate how events interact with event handlers, and I will explain how they can solve general problems. Some of the information may not be new to you, but if you do not have a deep understanding of the event, there will certainly be something to surprise you. Download the two sample applications (Visual Basic. net. 2002 and 2003, and Visual Basic 2005) in any case. All content applies to Visual Basic. net2002 and 2003 and Visual Basic 2005. Except for the last part about custom events, it can only work in Visual Basic 2005.

I will assume that you have some basic knowledge about delegation and multi-channel broadcast delegation. If you have not studied these important Microsoft. NET Framework features, you should do it now. For more information about these issues, see the Introduction to delegation in Ted pattison.

Event

Visual Basic (before Visual Basic. Net) provides you with a simple mechanism for creating and processing events, and Visual Basic. NET 2002 and 2003 provide several different ways to do them. Visual Basic 2005 even allows you to have stronger control over event handlers, as you will see in this article.

Events provide a loose contact mechanism that allows classes to register notifications that may or may not occur at a certain time in the future. If the "listeners" receive notifications about the events they are waiting for, they will handle this situation. If not, they only keep listening. Click the function provided by the class to register the event handler. When a user clicks this button, the class of this button triggers the click event, all the listeners (which may be multiple Click Event Handlers of this button) run their code and continue to execute the code.

My sample programs include a set of classes (filesearch1 to filesearch5 for Visual Basic. NET 2002 and 2003, while filesearch1 to filesearch6 can be used in Visual Basic 2005) to search for a file at a specified location and trigger an event when it is found. The filesearch class only listens to a corresponding class when something interesting occurs. In this case, an interesting thing happens whenever the filesearch class discovers another file. Many listener classes may want to respond to this event.

From the. NET perspective, a class can trigger an event at any point in code execution. Other classes can subscribe to this event, and they can receive notifications through. NET Framework when the event occurs. The class that triggers the event generally does not know how many listeners (if any) there are, although it may make some effort to collect this information, as you will see later in this article. In addition, multiple listeners can be registered to receive notifications, and each listener can be notified without knowing anything about other listeners.

Process with Visual Basic 6.0

Designers of. NET Framework and Visual Basic. Net have done a lot of work to ensure that you can use events in. NET as you did in Visual Basic 6.0. You can:

* Declare an event using the event keyword

* Use the raiseevent statement to raise an event

* Use a withevents variable to process events

What is essentially different from. NET is the underlying mechanism. Visual Basic. net uses a visible, scalable, and public plumbing-delegate to manage event processing in Visual Basic 6.0.

Another difference between Visual Basic 6.0 and Visual Basic. NET is in. Net: You can use the handles clause to indicate a special process that should be run in the response to a special event. The handles clause allows any process that matches the event's parameter signature to respond to this event. It sounds like a delegate, but under the representation, it is a delegate. At the Compilation Time,. NET Framework uses your event name to create a delegate class, but adds "eventhandler" at the end. For example, when you declare an event named filefound,. NET Framework creates a delegate type named filefoundeventhandler for you. Each process for processing this event must have a signature that complies with the delegate type.

Click the raiseevent button on the example form to demonstrate how Visual Basic. Net supports Event Processing Based on Visual Basic 6.0. The example project includes the filesearch1 class, which uses the following code to create an event:

''The following code is from filesearch1.vb.
Public class filesearch1
''Search for files at the specified location
''Once found, this class triggers the filefound event for each found file.
Public event filefound (byval Fi as fileinfo)... ''the code here is removed...

End Class

When it finds a file, the filesearch1 class triggers the filefound event:

''The following code is from filesearch1.vb.
Dim AFI () as fileinfo = dilocal. getfiles (Me. filespec)
For each Fi as fileinfo in AFI
Raiseevent filefound (FI)
Next
Alfiles. addrange (AFI)

In frmmain. VB, you will find the following declaration, which allows the code to use the fs1 variable to respond to events triggered by the filesearch1 instance:

Private withevents fs1 as filesearch1

Click raiseevent to run the following code:

''The following code is from filesearch1.vb.
Fs1 = new filesearch1 (_
Me.txt searchpath. Text, me.txt filespec. Text ,_
Me. chksearchsubfolders. Checked) Try
Fs1.execute ()
Catch
End try

Finally, frmmain. VB includes an event handler that processes the filesearch1.filefound event:

''The following code is from filesearch1.vbprivate sub eventhandler1 (_
Byval newfile as system. Io. fileinfo )_
Handles fs1.filefound addtext ("eventhandler1:" & newfile. fullname)
End sub

Although frmmain. VB only includes a single process for processing the filesearch1.filefound event, it is quite possible (and likely) that you have more than one process to process a specific event ). This means that when the filesearch1 class triggers its filefound event, it is possible to process multiple processes. This should sound like the concept of multi-channel broadcast delegation, because it is a multi-channel broadcast delegation. In essence,. Net converts an event to a delegate class. If you use ildasm.exe to study il (intermediate code), we will see the cloud.

Research events with ildasm

If you use ildasm (included in.. NET Framework SDK. net Framework il Disassembly tool) to open the executable version of this example, you will get the information you see in Figure 1. Although filesearch1 does not explicitly contain a multi-channel broadcast delegate named filefoundeventhandler, Visual Basic.. Net compiler has created a (Multicast delegate), which corresponds to the type defined by the filefound event declared by the Code. The compiler also creates an instance named filefoundevent that represents the delegate type filefoundeventhandler of the event listener.

Figure 1 sample code in ildasm
With this technology, the compiler can force the parameter signature strictly following your event declaration, you don't have to worry about creating your own delegate type and the predefined type in your event declaration. As you will see later, you can create your own delegate to indicate your event and use this delegate as your event type.

Multi-Event Handler

The next class I will discuss is filesearch2, which is a similar copy of filesearch1. The only difference in using filesearch2 is that the example form contains multiple listeners for filefound events of the filesearch2 class. This is, frmmain. VB includes the following declaration:

''The following code is from filesearch1.vb.
Private withevents fs2 as filesearch2

The sample form also contains the event handler shown in figure 2. These Event Handlers also listen to filefound events caused by filesearch3 and filesearch4, which I will talk about below.

'From frmmain. VB
Private sub eventhandler2 (_
Byval newfile as system. Io. fileinfo )_
Handles fs2.filefound, fs3.filefound, fs4.filefound
Addtext ("eventhandler2:" & newfile. fullname)
End sub

Private sub eventhandler3 (_
Byval newfile as system. Io. fileinfo )_
Handles fs2.filefound, fs3.filefound, fs4.filefound

Addtext ("eventhandler3:" & newfile. fullname)
End sub

Click the multi-listener button on the main form to create a filesearch2 class instance. Call the execute method of this instance to display the output shown in 3.

Figure 3 multiple listeners allows multiple procedures to run
But note that when you use multiple handles clauses to respond to the same event, you cannot control the sequence in which the event handlers run .. . NET Framework provides two options.ArticleIt allows you to gain stronger control over multiple listeners. Multiple event handlers)
As you have seen, everything is satisfying. If you have multiple event handlers, the. NET Framework calls each handler in sequence when the event is triggered. So far, everything went well. What will happen if one of the Event Handlers generates an exception? This is not so smooth.

To confirm the problem, click the raiseevent error button on the example form. In this example, a new instance of the filesearch3 class is created (there is nothing new in this class itself ). In the example form shown in figure 4, several processes are provided, which process the filesearch3.filefound event, but one process throws an exception.

 

Figure 5 an error is thrown by an event listener

Figure 4 one event handler raises an error
'From frmmain. VB
Private sub eventhandler2 (_
Byval newfile as system. Io. fileinfo )_
Handles fs2.filefound, fs3.filefound, fs4.filefound

Addtext ("eventhandler2:" & newfile. fullname)
End sub

Private sub eventhandler3 (_
Byval newfile as system. Io. fileinfo )_
Handles fs2.filefound, fs3.filefound, fs4.filefound

Addtext ("eventhandler3:" & newfile. fullname)
End sub

Private sub eventhandler4 (_
Byval newfile as system. Io. fileinfo )_
Handles fs3.filefound, fs4.filefound

Addtext ("eventhandler4: throwing exception! ")
Throw new argumentexception
End sub

What will happen when you run this code? You will get the results shown in Figure 5. If any event listener raises an exception, the entire "Event-handling chain" will stop. If you stop and think about what is going on, you will know that this behavior makes sense.

 

Study abnormal behaviors

I will show you the code selected from filesearch3 soon. Every time a class instance finds a file, the instance triggers its filefound event. This effect causes. NET Framework to run each event processing process one after another. Take a look at the following code:

''The following code is from filesearch3.vb.
''Search for the matching file name
Dim AFI () as fileinfo = dilocal. getfiles (Me. filespec) for each Fi as fileinfo in AFI
'', Which is equivalent:
''Filefoundeventhandler. Invoke (FI)
Raiseevent filefound (FI)
Next
Alfiles. addrange (AFI)

This technical problem (as you have seen) is: if an exception occurs in any listener, the exception rollback (bubbles back) is triggered by the event-raising) code ,.. NET Framework no longer calls the event listener, but the event processing Slowly stops.

If you check that Il is generated for the sample code, the situation becomes clear. Figure 6 shows the disassembly of the filesearch3.search method in ildasm. The raiseevent statement you see in the class will not be compiled until a filefoundeventhandler. Invoke method is called. Internally, once this method has been called, your code gives control to the delegate execution process. If an unhandled exception occurs anywhere in the call list, this exception is rolled back to the caller (this code) without the listener getting the call.

Here is a solution. Instead of calling the raiseevent statement over and over again, it may explicitly call each individual listener for you. You can use the delegate class members to solve the unhandled exceptions in multiple listeners.

Manually call each listener

Although the raiseevent mechanism is convenient (and comfortable, if you use Visual Basic 6.0), it also has its disadvantages, as you have seen. It is better to call the event listener than to call events raiseevent: You can do this on your own. The flexibility you get is at the cost of giving up the comfort of raiseevent.

If you want to fully control the call of the event listener, instead of simply wanting the desired solution, you will need to use the implicit filefoundeventhandler delegate type. You can call the getinvocationlist method of the event delegate instance to obtain an array of listeners containing all events. Once you have this list, you can independently call the invoke method of each listener and capture any exceptions caused by the event handler. If any listener raises an exception, you can process it and continue the program.
Filesearchclass 4 contains code 7 in its search method. Click the getinvocationlist button on the sample form to run the code. As you will see, the example still calls the event listener that raises an error, but in this case, the code will not stop searching for files when the first listener raises an error. Because the filesearch4.search method includes the code that calls each listener independently, it can also handle exceptions for each call.

'From filesearch4.vb
Dim listenerlist () as system. Delegate
Dim listener as filefoundeventhandler
Listenerlist = filefoundevent. getinvocationlist ()
'Search for matching file names.
Dim AFI () as fileinfo = dilocal. getfiles (Me. filespec)

For each Fi as fileinfo in AFI
For each listener in listenerlist
Try
Listener. Invoke (FI)
Catch
'Something goes wrong? Just move on
'The next event handler.
End try
Next
Alfiles. addrange (AFI)
Next

The new code in filesearch4.search takes the following actions:

* Declare an array of the system. Delegate type so that the code can track all the event listeners:

Dim listenerlist () as system. Delegate

* Declare an instance that describes the event Delegate type to traverse the listener array (you should remember that all listener processes must have their specific types; otherwise, this Code cannot be compiled, this is how the delegate works ):

Dim listener as filefoundeventhandler

* Obtain the listener list again and call the internal getinvocationlist method entrusted by filefoundevent:

Listenerlist = filefoundevent. getinvocationlist ()

* Find the file and traverse the array containing cor-responding fileinfos, as you have seen before:

Dim AFI () as fileinfo = dilocal. getfiles (Me. filespec)

For each Fi as fileinfo in AFI
''Code removed here...
Next

* Every time a file is found, filesearch4.search traverses the list of Event Listeners and independently calls the callback (invoke) method of each delegate. This allows code capture (and in this case, ignore) any exceptions caused by each independent listener.

For each listener in listenerlist
Try
Listener. Invoke (FI)
Catch
''What's wrong? Only forward to the next event handler
End try
Next

 

In this example, neither the filefoundeventhandler type nor the filefoundevent variable are declared. The Visual Basic. Net compiler creates these entries when detecting event declarations in your code. Although you can declare these objects by yourself to eliminate ambiguity, you do not need to do this because the Visual Basic. Net compiler will do this for you.

In Visual Basic. NET 2002 and 2003, you cannot modify the method in which the. Net-based application triggers their own internal events. (You can modify this behavior in Visual Basic 2005, as you will see later) when you use a version earlier than Visual Basic 2005, there is a way to ensure that you do not cause problems in your event listener (remember: An unhandled exception in any event handler will cause.. NET Framework stops calling the listener for the current event ). To do so, make sure that rollback is not allowed for your own event processing. If you want to obtain a single event for processing through multiple event processes, you can handle all exceptions during your event process so that you do not break the chain of the event processing program.

Use the. NET event Design Mode

Although there is no error in triggering events as you may do in Visual Basic 6.0 and in my previous examples ,. net Framework has adopted a special design pattern for events, a design pattern you should adopt in your applications. In this mode, all events provide two parameters: an object, and a reference to the event (generally named sender) object, and an eventargs object (or an object inherited from eventargs), provide relevant information to the event (generally named E ).

Three suggestions are added for the Design Pattern of standard. NET Framework events. First, if your event needs to pass any information to its listener, you should create a class inherited from eventargs and it contains additional information. You can use the constructor of your class to accept and store information. In the example project, filefoundeventargs Class 8 is shown.
Second, provide a process for triggering events. Most. NET Framework classes trigger events from an overloaded protected process, which is generally named oneventname (in the case of a filefound event, the process will be named onfilefound ). The code that needs to trigger the event calls the oneventname process, which then triggers the event. Making it a protected method means that it can be used for the current type of objects and for any objects inherited from the current class. Overloading it means that the inheritance class can change the event behavior: an inheritance class can be added to the code before or after the oneventname process of the base class is called, or you can skip them all. In this example project, the filesearch5 class provides the following protected process:

'From filefoundeventsargs. VB
Public class filefoundeventargs
Inherits eventargs
Private MFI as fileinfo

Public readonly property filefound () as fileinfo
Get
Return MFI
End get
End Property

Public sub new (byval Fi as fileinfo)
'Store the fileinfo object for later use.
MFI = Fi
End sub
End Class ''from filesearch9.vb
Protected overridable sub onfilefound (byval Fi as fileinfo)
Raiseevent filefound (Me, new filefoundeventargs (FI ))
End sub

This process uses the first parameter of the raiseevent statement to pass the keyword me. This keyword references the object in the currently running Code. It is of course the object that triggers the event.

Third, you may find it useful to create your own event Delegate. Although you do not need to define an explicit event Delegate to obtain the event Delegate, you can gain some flexibility when creating your own event Delegate. When you create a delegate, you are defining a "type" for the process ". If you have more than one event and they need the same set of parameters, it will be useful to create a delegate that defines this type. If you need to modify these parameters, you only need to modify the delegate without modifying the event declaration.

For example, you can declare this filefound event without event delegation, as shown below:

Public event filefound (_
Byval sender as object, byval e as filefoundeventargs)

If you want to declare other events and use the same parameters, you must repeat the entire declaration:

Public event filefoundsomeotherevent (_
Byval sender as object, byval e as filefoundeventargs)

You can also declare a new delegate type, which describes the parameter signature of your event:

Public Delegate sub filefoundeventhandler (_
Byval sender as object, byval e as filefoundeventargs)

In this case, you should declare this type of declaration event:

Public event filefound as filefoundeventhandler
Public event filefoundsomeotherevent as filefoundeventhandler

If you do not take this extra step, the Visual Basic. Net compiler will do this for you and add a new delegate type to the metadata of the class. The filesearch5.search method uses this mechanism to call the onfilefound method when each file is found:

''From filesearch5.vb
Dim AFI () as fileinfo = dilocal. getfiles (Me. filespec)
For each Fi as fileinfo in AFI
Onfilefound (FI)
Next

Click the event Design Pattern button on the sample form to create a filesearch5 class instance and call its execute method (as in all previous examples ). In this case, the event handler for the filesearch5.filefound event is a bit different: rather than accepting only one fileinfo object, this event handler looks like a standard. net event handler. It accepts two parameters and uses the filefound attribute of the filefoundeventargs parameter to display the found File Name:

''From frmmain. VB
Private sub fs5_filefound (_
Byval sender as object, byval e as filefoundeventargs )_
Handles fs5.filefound
Addtext (E. filefound. fullname)
End sub

Although you do not need to use the standard. Net event processing design pattern, it always matches your own events with the events triggered by internal. Net objects. You get the benefit of being "familiar" in your event listeners and they look like other events. It is optional to create your own event Delegate. However, if multiple events pass the same parameters, you can use event Delegate to simplify your code. In addition, because the modification of event parameters can only be performed in one place, it is easier to modify your code at any time as needed.

 

Dynamically add and remove handlers

All the Event Listeners you have seen so far need to be associated with the event handler at design. The handles clause is a convenient and simple method for associating objects that use the withevents keyword to trigger events, but it cannot provide any flexibility during runtime. In addition, when multiple processes process the same event, the handles clause does not give you control over the execution sequence of the event handler. (Of course, to avoid this problem, you can use the technique you saw earlier to traverse the returned items by calling getinvocationlist. This technology requires additional code of the class that triggers the event, not in the code of the associated event listener .)

You can use the addhandler (and removehandler) statement instead of the handles clause to obtain full initiative when and in what order to call the event handler. The addhandler and removehandler statements allow you to provide an address for a specific event and the process of preparing to respond to the event called. Each call to addhandler associates the process with the event so that the. NET Framework calls the process when an event occurs. In addition, addhandler always adds the event handler to the end of the event call list. This means that you control the order in which events are processed.

Of course, if you think about it for a moment, you will understand that when you have multiple processes, the same event has a handles clause, the Visual Basic compiler creates a multicast delegate instance for the event handler without allowing you to control the order in which they are added. The events that are triggered call the invoke method of the delegate instance. In this case, they are called in the order in which each event listener is added (and you do not have permission to control this order. When you use the addhandler and removehandler statements instead of the handles clause, you only need to simply control the order in which each item is added to the multi-channel broadcast delegate. Every time your application calls the addhandler statement for the same event, you add a new listener to the end of the list. When you initiate this event, the. NET runtime calls each listener in sequence.

If you click the Add/removehandler button in the example form, a new filesearch5 class instance is created, and multiple event handlers of the Instance's filefound event are integrated (hooked up ). When the code calls the execute method of the instance, The ListBox control of the example form displays the result:

''From frmmain. VB
Dim fs5 as new filesearch5 (_
Me.txt searchpath. Text, me.txt filespec. Text ,_
Me. chksearchsubfolders. Checked)
Addhandler fs5.filefound, addressof eventhandler7
Addhandler fs5.filefound, addressof eventhandler6
Addhandler fs5.filefound, addressof eventhandler5
Addtext ("note the order of invocation :")
Fs5.execute ()

Then, the Code removes eventhandler7 from the callback list and calls the execute method again:

Removehandler fs5.filefound, addressof eventhandler7
Addtext (string. Empty)
Addtext ("and then there were two :")
Fs5.execute ()

Finally, the Code removes the remaining Event Handlers:

Removehandler fs5.filefound, addressof eventhandler6
Removehandler fs5.filefound, addressof eventhandler5

Remember, when you call the addhandler and removehandler statements, the process of providing the address must have the correct delegate type. Therefore, unless the signature of the process parameters provided to addhandler and removehandler addresses matches the event parameters (that is, unless they have the correct delegate type ), otherwise, your code cannot be compiled.

Figure 9 sequence of event handler callback
Figure 9 shows the Add/removehandler button. As you can see, the event process is called in the order you add them to the callback list.
Custom events in Visual Basic

Remember the problem that occurs when an event has multiple listeners. Is there another event listener that throws an exception? There is a quite simple solution to this problem. The event is associated with the callback list of the multi-channel broadcast delegate instance. However, in Visual Basic. NET 2002 and 2003, there are some other event challenges: (if there is no complicated or inefficient code, a simple (method) will not be reflected. Before Visual Basic 2005, an instance of the event Delegate type is always created by the Visual Basic compiler for you, And the compiler cannot provide you with the behavior to modify this delegate instance.

Visual Basic 2005 adds a new custom keyword for the event declaration. This keyword allows you to provide code for the addhandler, removehandler, and raiseevent actions of the event. It depends on the type of the Delegate and the type of the event listener that you have created. However, you have full control over how you handle events.

To create a custom event in Visual Studio 2005, put your cursor in a class and enter a declaration for your event, as shown below:

Public Custom Event <youreventname> as <eventdelegatetype>

When you complete this line of code, the Editor inserts the associated addhandler, removehandler, and raiseevent sections. For example, imagine that you want to solve the exception by creating a Custom Event Handler. The filesearch6 class of Visual Basic 2005 of the sample project contains a custom filefound event like this. The Code includes a declaration of an appropriate event Delegate, as shown below:

Public Delegate sub filefoundeventhandler (_
Byval sender as object, byval e as filefoundeventargs)

Type the event declaration to add an empty custom event, as shown in 10.

Public Custom Event filefound as filefoundeventhandler
Addhandler (byval value as filefoundeventhandler)

End addhandler

Removehandler (byval value as filefoundeventhandler)

End removehandler

Raiseevent (byval sender as object, byval e as filefoundeventargs)

End raiseevent
End event

This requires you to provide storage for the event delegate instance, and provide the code to store, remove, and callback the event listener. In this example, because the code needs to be able to independently call back each listener and capture and handle any exceptions, the filesearch6 class includes a set of generic lists (generic list collection) that stores the filefoundeventhandler instance ). Each time any class calls addhandler for this event, or uses a handles clause to capture this event, the Visual Basic Runtime Engine calls the addhandler section of the filefound Custom Event. The code must add filefoundeventhandler to pass to the generic list. The removehandler part removes the specified delegate instance from the internal set. Raiseevent calls the invoke method of each delegate instance to capture and handle exceptions. Full custom events look like code 11.

Private listeners as new list (of filefoundeventhandler)
Public Custom Event filefound as filefoundeventhandler
Addhandler (byval value as filefoundeventhandler)
Listeners. Add (value)
End addhandler

Removehandler (byval value as filefoundeventhandler)
If listeners. Contains (value) then
Listeners. Remove (value)
End if
End removehandler

Raiseevent (byval sender as object, byval e as filefoundeventargs)
For each listener as filefoundeventhandler in listeners
Try
Listener. Invoke (sender, E)
Catch ex as exception
'Something goes wrong? Just move on to the next handler.
End try
Next
End raiseevent
End event

By advancing the code to the event Declaration itself, the code that triggers the event no longer needs to worry about handling exceptions. This means that, unlike using the code you saw earlier to trigger an event, the Code assumes that the filesearch6 class in Visual Basic 2005 can simply call the onfilefound method (which triggers an event) or directly call raiseevent. The responsibility for worrying about exceptions is now appropriate: it is in the event Code itself. This technology is available only after Visual Basic 2005. Note that Visual Studio 2005 is still in beta (testing ). Because of this, the details will change before the final version is released.

are there other custom events available? Rocky lhotka, a visual basic MVP, includes another detailed example (. NET 2.0 solution to serialization of objects that raise events) on his blog ). He discussed that you may use this technology to solve the problem of triggering event-class serialization and the listener is not serialized. (Surprisingly, this often happens because the form is not serialized, but the listener for event creation is often serialized .) Paul Vick is a member of Microsoft's Visual Basic Development Team, his blog includes an example to show how you can use a Custom Event to reduce the system overhead of classes that are exposed to a large number of events and only a small number of events may be used. This is the case for forms. For example, the form class is exposed to a large number of events, but most of the time, you only process one or two of them. Without some tips, the compiler will trigger a delegate instance for each event, although you will not use them. Please refer to Paul's blog in custom events.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.